Skip to content

Commit

Permalink
style: pep8 imports
Browse files Browse the repository at this point in the history
Also incorporates some recommendations from pep-257 on docstring
conventions.
  • Loading branch information
jeffwidman committed Jul 24, 2017
1 parent 83b9f94 commit aff2257
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 77 deletions.
45 changes: 19 additions & 26 deletions kazoo/client.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Kazoo Zookeeper Client"""
from collections import defaultdict, deque
from functools import partial
import inspect
import logging
from os.path import split
import re
import warnings
from collections import defaultdict, deque
from functools import partial
from os.path import split

import six

Expand All @@ -25,8 +25,7 @@
from kazoo.hosts import collect_hosts
from kazoo.loggingsupport import BLATHER
from kazoo.protocol.connection import ConnectionHandler
from kazoo.protocol.paths import normpath
from kazoo.protocol.paths import _prefix_root
from kazoo.protocol.paths import _prefix_root, normpath
from kazoo.protocol.serialization import (
Auth,
CheckVersion,
Expand All @@ -44,33 +43,27 @@
Sync,
Transaction
)
from kazoo.protocol.states import Callback
from kazoo.protocol.states import EventType
from kazoo.protocol.states import KazooState
from kazoo.protocol.states import KeeperState
from kazoo.protocol.states import WatchedEvent
from kazoo.protocol.states import (
Callback,
EventType,
KazooState,
KeeperState,
WatchedEvent
)
from kazoo.retry import KazooRetry
from kazoo.security import ACL
from kazoo.security import OPEN_ACL_UNSAFE
from kazoo.security import ACL, OPEN_ACL_UNSAFE

# convenience API
from kazoo.recipe.barrier import Barrier
from kazoo.recipe.barrier import DoubleBarrier
from kazoo.recipe.barrier import Barrier, DoubleBarrier
from kazoo.recipe.counter import Counter
from kazoo.recipe.election import Election
from kazoo.recipe.lease import NonBlockingLease
from kazoo.recipe.lease import MultiNonBlockingLease
from kazoo.recipe.lock import Lock
from kazoo.recipe.lock import ReadLock
from kazoo.recipe.lock import WriteLock
from kazoo.recipe.lock import Semaphore
from kazoo.recipe.lease import NonBlockingLease, MultiNonBlockingLease
from kazoo.recipe.lock import Lock, ReadLock, WriteLock, Semaphore
from kazoo.recipe.partitioner import SetPartitioner
from kazoo.recipe.party import Party
from kazoo.recipe.party import ShallowParty
from kazoo.recipe.queue import Queue
from kazoo.recipe.queue import LockingQueue
from kazoo.recipe.watchers import ChildrenWatch
from kazoo.recipe.watchers import DataWatch
from kazoo.recipe.party import Party, ShallowParty
from kazoo.recipe.queue import Queue, LockingQueue
from kazoo.recipe.watchers import ChildrenWatch, DataWatch


string_types = six.string_types
bytes_types = (six.binary_type,)
Expand Down
4 changes: 2 additions & 2 deletions kazoo/handlers/eventlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import contextlib
import logging

import kazoo.python2atexit as python2atexit

import eventlet
from eventlet.green import select as green_select
from eventlet.green import socket as green_socket
Expand All @@ -14,6 +12,8 @@
from eventlet import queue as green_queue

from kazoo.handlers import utils
import kazoo.python2atexit as python2atexit


LOG = logging.getLogger(__name__)

Expand Down
8 changes: 4 additions & 4 deletions kazoo/handlers/gevent.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
import logging

import gevent
from gevent import socket
import gevent.event
import gevent.queue
import gevent.select
import gevent.thread

from gevent.queue import Empty
from gevent.queue import Queue
from gevent import socket
import gevent.select
import gevent.thread
try:
from gevent.lock import Semaphore, RLock
except ImportError:
Expand All @@ -20,6 +19,7 @@
from kazoo.handlers import utils
from kazoo import python2atexit


_using_libevent = gevent.__version__.startswith('0.')

log = logging.getLogger(__name__)
Expand Down
8 changes: 4 additions & 4 deletions kazoo/handlers/threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@
"""
from __future__ import absolute_import

from collections import defaultdict
import errno
from itertools import chain
import logging
import select
import socket
import threading
import time
import six

from collections import defaultdict
from itertools import chain
import six

import kazoo.python2atexit as python2atexit
from kazoo.handlers import utils

try:
import Queue
except ImportError: # pragma: nocover
import queue as Queue

from kazoo.handlers import utils

# sentinel objects
_STOP = object()
Expand Down
6 changes: 3 additions & 3 deletions kazoo/protocol/connection.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
"""Zookeeper Protocol Connection Handler"""
from binascii import hexlify
from contextlib import contextmanager
import logging
import random
import select
import socket

import sys
import time
from binascii import hexlify
from contextlib import contextmanager

from kazoo.exceptions import (
AuthFailedError,
Expand Down Expand Up @@ -41,6 +40,7 @@
RetryFailedError
)


log = logging.getLogger(__name__)


Expand Down
3 changes: 2 additions & 1 deletion kazoo/protocol/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
from collections import namedtuple
import struct

import six

from kazoo.exceptions import EXCEPTIONS
from kazoo.protocol.states import ZnodeStat
from kazoo.security import ACL
from kazoo.security import Id

import six

# Struct objects with formats compiled
bool_struct = struct.Struct('B')
Expand Down
4 changes: 2 additions & 2 deletions kazoo/python2atexit.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""Uses the old atexit with added unregister for python 2.x
and the new atexit for python 3.x
"""

import sys
import atexit
import sys


__all__ = ["register", "unregister"]

Expand Down
4 changes: 1 addition & 3 deletions kazoo/recipe/barrier.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
import socket
import uuid

from kazoo.exceptions import KazooException, NoNodeError, NodeExistsError
from kazoo.protocol.states import EventType
from kazoo.exceptions import KazooException
from kazoo.exceptions import NoNodeError
from kazoo.exceptions import NodeExistsError


class Barrier(object):
Expand Down
5 changes: 2 additions & 3 deletions kazoo/recipe/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
See also: http://curator.apache.org/curator-recipes/tree-cache.html
"""

from __future__ import absolute_import

import os
import logging
import contextlib
import functools
import logging
import operator
import os

from kazoo.exceptions import NoNodeError, KazooException
from kazoo.protocol.states import KazooState, EventType
Expand Down
1 change: 0 additions & 1 deletion kazoo/recipe/counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
:Status: Unknown
"""

from kazoo.exceptions import BadVersionError
from kazoo.retry import ForceRetryError

Expand Down
4 changes: 2 additions & 2 deletions kazoo/recipe/lease.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
:Status: Beta
"""

import datetime
import json
import socket
import datetime

from kazoo.exceptions import CancelledError


Expand Down
17 changes: 9 additions & 8 deletions kazoo/recipe/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
and/or the lease has been lost.
"""

import sys
try:
from time import monotonic as now
Expand All @@ -24,16 +23,18 @@

import six

from kazoo.exceptions import (
CancelledError,
KazooException,
LockTimeout,
NoNodeError
)
from kazoo.protocol.states import KazooState
from kazoo.retry import (
ForceRetryError,
KazooRetry,
RetryFailedError,
ForceRetryError
RetryFailedError
)
from kazoo.exceptions import CancelledError
from kazoo.exceptions import KazooException
from kazoo.exceptions import LockTimeout
from kazoo.exceptions import NoNodeError
from kazoo.protocol.states import KazooState


class _Watch(object):
Expand Down
3 changes: 2 additions & 1 deletion kazoo/recipe/partitioner.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
so that no two workers own the same queue.
"""
from functools import partial
import logging
import os
import socket
from functools import partial

from kazoo.exceptions import KazooException, LockTimeout
from kazoo.protocol.states import KazooState
from kazoo.recipe.watchers import PatientChildrenWatch


log = logging.getLogger(__name__)


Expand Down
4 changes: 2 additions & 2 deletions kazoo/recipe/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
See: https://github.com/python-zk/kazoo/issues/175
"""

import uuid

from kazoo.exceptions import NoNodeError, NodeExistsError
from kazoo.retry import ForceRetryError
from kazoo.protocol.states import EventType
from kazoo.retry import ForceRetryError


class BaseQueue(object):
Expand Down
5 changes: 3 additions & 2 deletions kazoo/recipe/watchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,19 @@
will result in an exception being thrown.
"""
from functools import partial, wraps
import logging
import time
import warnings
from functools import partial, wraps

from kazoo.retry import KazooRetry
from kazoo.exceptions import (
ConnectionClosedError,
NoNodeError,
KazooException
)
from kazoo.protocol.states import KazooState
from kazoo.retry import KazooRetry


log = logging.getLogger(__name__)

Expand Down
1 change: 1 addition & 0 deletions kazoo/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
SessionExpiredError,
)


log = logging.getLogger(__name__)


Expand Down
1 change: 0 additions & 1 deletion kazoo/security.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class ACL(namedtuple('ACL', 'perms id')):
a :class:`Permissions` setting. For convenience,
:meth:`make_digest_acl` should be used to create an ACL object with
the desired scheme, id, and permissions.
"""
@property
def acl_list(self):
Expand Down
3 changes: 1 addition & 2 deletions kazoo/testing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from kazoo.testing.harness import KazooTestCase
from kazoo.testing.harness import KazooTestHarness
from kazoo.testing.harness import KazooTestCase, KazooTestHarness


__all__ = ('KazooTestHarness', 'KazooTestCase', )
7 changes: 3 additions & 4 deletions kazoo/testing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@


import code
from collections import namedtuple
from glob import glob
from itertools import chain
import logging
import os
import os.path
Expand All @@ -30,10 +33,6 @@
import tempfile
import traceback

from itertools import chain
from collections import namedtuple
from glob import glob


log = logging.getLogger(__name__)

Expand Down
Loading

0 comments on commit aff2257

Please sign in to comment.