From: Daniele Varrazzo Date: Thu, 28 Oct 2021 11:34:45 +0000 (+0200) Subject: Clean up imports/exports in psycopg package X-Git-Tag: 3.0.2~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89958f0a43d30d5cfc49350541aab9764244438d;p=thirdparty%2Fpsycopg.git Clean up imports/exports in psycopg package 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. --- diff --git a/psycopg/psycopg/__init__.py b/psycopg/psycopg/__init__.py index 40e73eb0a..368b8ef66 100644 --- a/psycopg/psycopg/__init__.py +++ b/psycopg/psycopg/__init__.py @@ -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 744d94ebf..3d4a50947 100644 --- 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