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

Types not explicitly exported from package #118

Closed
johnthagen opened this issue Nov 25, 2024 · 5 comments · Fixed by #119
Closed

Types not explicitly exported from package #118

johnthagen opened this issue Nov 25, 2024 · 5 comments · Fixed by #119

Comments

@johnthagen
Copy link
Contributor

johnthagen commented Nov 25, 2024

The following code:

from parsita import Success

Raises the following error from Mypy when run in strict mode:

main.py:1: error: Module "parsita" does not explicitly export attribute "Success"  [attr-defined]

I believe this is because there is no __all__ defined in

This also applies to other types re-exported from the base parsita package, such as Parser, Result, etc.

Environment

  • Python 3.11
  • parsita 2.2.0
  • mypy 1.13.0
[tool.mypy]
strict = true

Related to

@johnthagen johnthagen changed the title Result types not explicitly exported from package Types not explicitly exported from package Nov 25, 2024
@drhagen
Copy link
Owner

drhagen commented Nov 26, 2024

If there is a solution to this that is not "Relist everything in all", I'll do it. Otherwise, I am going to follow other projects and declare this WONTFIX.

@drhagen
Copy link
Owner

drhagen commented Nov 26, 2024

Ruff has a similar lint, but I globally disable it. However, I don't see any evidence that such a targeted disable is available. It looks like MyPy+Parsita users putting in no_implicit_reexport = False is the narrowest fix.

@johnthagen
Copy link
Contributor Author

If there is a solution to this that is not "Relist everything in __all__"

It looks like you can also signal the intention to re-export by

from .state import (
    Failure as Failure

There is still duplication, but at least it's localized?

@johnthagen
Copy link
Contributor Author

I am going to follow other projects and declare this WONTFIX.

One of the referenced projects, click, actually did reverse their decision and make the change

I agree this is not optimal and it would be nice if Mypy had a way to opt out of this feature only for a particular dependency, but turning off this check for an entire application also has other downsides in that you then can accidentally import things from the wrong location in your own codebase.

@johnthagen
Copy link
Contributor Author

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 a pull request may close this issue.

2 participants