Skip to content
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

Explicitly export values on factory namespace #1114

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

Conversation

DavidCain
Copy link

Now that factory-boy exports its types, mypy will fail in strict mode
if using the factory namespace. Specifically, --no-implicit-reexport
flags references to factory.Factory (and other similar values) as
being implicitly exported:

$ mypy --strict test.py
test.py:1:1: error: Module "factory" does not explicitly export attribute "Factory"  [attr-defined]
    from factory import Factory
    ^

We can instead explicitly export these objects. As a benefit, anybody
who uses the ill-advised from factory import * will now at least no
longer have __author__ and such pollute their namespace.

https://mypy.readthedocs.io/en/stable/config_file.html#confval-implicit_reexport

Now that `factory-boy` exports its types, mypy will fail in strict mode
if using the `factory` namespace. Specifically, `--no-implicit-reexport`
flags references to `factory.Factory` (and other similar values) as
being implicitly exported.

We can instead *explicitly* export these objects. As a benefit, anybody
who uses the ill-advised `from factory import *` will now at least no
longer have `__author__` and such pollute their namespace.

https://mypy.readthedocs.io/en/stable/config_file.html#confval-implicit_reexport
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant