]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
Clean up imports/exports in psycopg package
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 28 Oct 2021 11:34:45 +0000 (13:34 +0200)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Thu, 28 Oct 2021 14:38:18 +0000 (16:38 +0200)
Drop file-level F401 ignore and declare explicitly what is exported.

Something reordered to keep together package-level types registration,
to use a somewhat alphabetical order to group of things.

psycopg/psycopg/__init__.py
tox.ini

index 40e73eb0a309e7b4cd282dd5864f82e4cd7288d5..368b8ef6677593f3990e9cc5a678b6343974a6a7 100644 (file)
@@ -6,7 +6,7 @@ psycopg -- PostgreSQL database adapter for Python
 
 import logging
 
-from . import pq
+from . import pq  # noqa: F401 import early to stabilize side effects
 from . import types
 from . import postgres
 from .copy import Copy, AsyncCopy
@@ -25,8 +25,7 @@ from .connection_async import AsyncConnection
 
 from . import dbapi20
 from .dbapi20 import BINARY, DATETIME, NUMBER, ROWID, STRING
-from .dbapi20 import Binary, BinaryTextDumper, BinaryBinaryDumper
-from .dbapi20 import Date, DateFromTicks, Time, TimeFromTicks
+from .dbapi20 import Binary, Date, DateFromTicks, Time, TimeFromTicks
 from .dbapi20 import Timestamp, TimestampFromTicks
 
 from .version import __version__
@@ -36,21 +35,20 @@ logger = logging.getLogger("psycopg")
 if logger.level == logging.NOTSET:
     logger.setLevel(logging.WARNING)
 
-# register default adapters for PostgreSQL
-adapters = postgres.adapters  # exposed by the package
-
 # DBAPI compliancy
 connect = Connection.connect
 apilevel = "2.0"
 threadsafety = 2
 paramstyle = "pyformat"
 
+# register default adapters for PostgreSQL
+adapters = postgres.adapters  # exposed by the package
 postgres.register_default_adapters(adapters)
 
-# After the default one because they can deal with the bytea oid better
+# After the default ones, because these can deal with the bytea oid better
 dbapi20.register_dbapi20_adapters(adapters)
 
-# Must come after all the types are registered
+# Must come after all the types have been registered
 types.array.register_all_arrays(adapters)
 
 # Note: defining the exported methods helps both Sphynx in documenting that
@@ -66,6 +64,7 @@ __all__ = [
     "BaseConnection",
     "Column",
     "Connection",
+    "ConnectionInfo",
     "Copy",
     "Cursor",
     "IsolationLevel",
@@ -89,16 +88,16 @@ __all__ = [
     "ProgrammingError",
     "NotSupportedError",
     # DBAPI type constructors and singletons
+    "Binary",
     "Date",
-    "Time",
-    "Timestamp",
     "DateFromTicks",
+    "Time",
     "TimeFromTicks",
+    "Timestamp",
     "TimestampFromTicks",
-    "Binary",
-    "STRING",
     "BINARY",
-    "NUMBER",
     "DATETIME",
+    "NUMBER",
     "ROWID",
+    "STRING",
 ]
diff --git a/tox.ini b/tox.ini
index 744d94ebf6ac741a345f4f172c9736e758da8ded..3d4a509472cb34813509cca14124180a9debd6c1 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -28,5 +28,3 @@ skip_install = true
 max-line-length = 85
 ignore = W503, E203
 extend-exclude = .venv
-per-file-ignores =
-    ./psycopg/psycopg/__init__.py: F401