-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
New semantic analyzer: Namespace package with __init__.py breaks analysis #7029
Comments
Can you give some examples of the code that triggers this? |
presenter: BasePresenter = PresenterHelper.get_presenter(options=presenter_args)
if isinstance(presenter, (ConsolePresenter, JsonPresenter, MarkdownPresenter)):
presenter.save_to_file(records, args.documents, args.output)
theme_manager: ThemeManager = ThemeManager(args.output)
from Extensions import HelpFormatterEx
if __name__ == '__main__':
_parser = argparse.ArgumentParser(formatter_class=HelpFormatterEx)
The overarching pattern seems to be related to package imports. |
Can you show the place in |
Tree:
from Extensions.HelpFormatterEx import HelpFormatterEx
import argparse
class HelpFormatterEx(argparse.HelpFormatter):
def _format_action_invocation(self, action: argparse.Action) -> str:
# snip |
There must be something else, this test passes cleanly:
Do you have any tricky import cycles and/or forward references there? |
I just tried to repro this specifically in a new project, but I got the same result as you. It's possible the error is somewhere else and tripping up the other checks. I'll try to narrow it down. |
OK, thanks! |
Okay, I found the error. The issue was I had an empty and errant Using the docs example tree as a reference:
If that file exists, mypy reports a ton of false-positive errors. Deleting that file clears up the report. |
Hm, interesting. Could you please post a self contained repro that you have? |
(I also added the usability label because the errors emitted make it hard to understand what went wrong, although it is kind of related to #4030). |
Here you go: mypytest.zip. |
I tried checking the zipped files with mypy master and mypy generates only two errors:
both with new and old analyzers. Also the errors look reasonable. |
To clarify, I don't see any bug here. |
Removed priority label for now since we don't have a repro. |
@ilevkivskyi These are my results.
Are you using the Did you try removing the empty If you remove the empty Python can run the application with or without the empty |
Yes, I use the (Btw note I use a recent master, not the released version.) |
The Mypy plugin for PyCharm has the ability to run Mypy on all files in the project. If I restore the empty
That's compared to the 18 errors in 8 files across the project with the new semantic analyzer enabled. Regardless of whether the new semantic analyzer enabled, Mypy's behaviour - with respect to namespace packages and I would also say that "module not callable" is not a reasonable error because it is false. |
Not fixed in 0.720. |
This looks somewhat similar to #7203. And I am also seeing false "... already defined (by an import)" errors with the new semantic analyzer. |
I'm getting a lot of errors reported that are not errors.
isinstance
are reported asincompatible type Module
(suggests that all custom types are treated as type Module)__init__.py
are reported as already definedI am not sure whether these are issues are caused by the new semantic analyzer or by the Mypy plugin for PyCharm which has not been updated yet.
In comparison, with the new semantic analyzer disabled, there are no errors. The application works correctly.
The text was updated successfully, but these errors were encountered: