Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Refactor exception classes #1129

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bryanforbes
Copy link
Collaborator

  • Moved PostgresMessageMeta and PostgresMessage into their own file to make it easier to add typings later on
  • Re-exported PostgresMessageMeta and PostgresMessage from asyncpg.exceptions._base to maintain backwards compatibility
  • Removed import asyncpg statements and import within methods to prevent circular imports

* Moved `PostgresMessageMeta` and `PostgresMessage` into their own file
  to make it easier to add typings later on
* Re-exported `PostgresMessageMeta` and `PostgresMessage` from
  `asyncpg.exceptions._base` to maintain backwards compatibility
* Removed `import asyncpg` statements and import within methods to
  prevent circular imports
import sys
import textwrap
# PostgresMessageMeta imported for backward compatibility
from ._postgres_message import ( # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add them to __all__. Then you won't need as and noqa.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I do that, then they will be imported with from ._base import * in asyncpg/exceptions/__init__.py, and then they will be accessible as asyncpg.PostgresMessage and asyncpg.PostgresMessageMeta

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants