konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.76k stars 106 forks source link

Fix mypy implicit reexport error #133

Closed markedwards closed 3 years ago

markedwards commented 3 years ago

If you try to import from_dict with no_implicit_reexport enabled in mypy, you get an error:

Module 'dacite' does not explicitly export attribute 'from_dict'; implicit reexport disabled

This is easily fixed by simply defining __all__ in dacite/__init__.py. I'm happy to do a PR if it helps.

Akuli commented 3 years ago

Alternatively, from dacite.core import from_dict as from_dict (yes, the same name repeated).

markedwards commented 3 years ago

Alternatively, from dacite.core import from_dict as from_dict (yes, the same name repeated).

You can just do from dacite.core import from_dict. But in any case this should be fixed.

Akuli commented 3 years ago

And it turns out that the star import doesn't really work either: https://github.com/python/mypy/issues/10198#issuecomment-855379374

Akuli commented 3 years ago

mypy.ini workaround:

# https://github.com/konradhalas/dacite/issues/133
[mypy-dacite]
implicit_reexport = True
gitpushdashf commented 3 years ago

I'm also running into this. Thanks for opening the issue.

konradhalas commented 3 years ago

hi @markedwards - thank you for reporting this issue. Should be fixed in a7834ba2421f6c52be8cd0f787660940deb9fc5b

jessestricker commented 2 years ago

As the fix is not released on PyPI yet, here is workaround for a pyproject.toml:

# https://github.com/konradhalas/dacite/issues/133
[[tool.mypy.overrides]]
module = "dacite"
implicit_reexport = true

(adapted from @Akuli)

ghost commented 1 year ago

tests/azure_devops/variable_groups/test_service.py:6: error: Module "lib_team_services_common.azure_devops.services" does not explicitly export attribute "VariableGroupService"; implicit reexport disabled this is the error , would you please help me fixing it