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

Conversation

wbolster
Copy link
Contributor

@wbolster wbolster commented Sep 20, 2021

Mypy reports attr-defined errors (via no_implicit_reexport) because the
‘maxminddb’ module uses implicit re-exports. Adding __all__ makes the
exported API surface explicit, which avoids the type checking errors.

Copy link
Member

@oschwald oschwald left a comment

Choose a reason for hiding this comment

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

Good idea. I had one thought.

"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

Mypy reports attr-defined errors (via no_implicit_reexport) because the
‘maxminddb’ module uses implicit re-exports. Adding __all__ makes the
exported API surface explicit, which avoids the type checking errors.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants