Skip to content

Expose __all__ to avoid type checking errors #87

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions maxminddb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@
from maxminddb.decoder import InvalidDatabaseError
from maxminddb.reader import Reader as PyReader

__all__ = [
"InvalidDatabaseError",
"MODE_AUTO",
"MODE_FD",
"MODE_FILE",
"MODE_MEMORY",
"MODE_MMAP",
"MODE_MMAP_EXT",
"PyReader", # Exposed for type checking b/c return type of open_database()
"Reader",
Copy link
Member

Choose a reason for hiding this comment

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

Rather than including these, perhaps we could export a particular type, e.g.:

ReaderTypes = Union[PyReader, "maxminddb.extension.Reader"]

I am not sure what the best naming would be here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i think it's best to expose a real base type. generally speaking, union return types are bad.

i suggest merging this as-is to simply establish the status quo, and cleaning up some things in another pull request.

for instance, maybe the oddly named Reader compat helper may be ditched in favour of something that can act as a proper type, and it may even be possible to do so without breaking API. i'll think about it some more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see #88

"open_database",
]


def open_database(
database: Union[AnyStr, int, os.PathLike, IO], mode: int = MODE_AUTO
Expand Down