-
-
Notifications
You must be signed in to change notification settings - Fork 276
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
Make astroid typable possibily with breaking change to permit most performance increase possibility #2060
Comments
Many node types have fields that are marked as optional when really they are required. These fields are assumed to be non-optional throughout the Astroid code, and that's a major source of type errors detected by Mypy. For example, consider the self.test: NodeNG | None = None
"""The test that passes or fails the assertion."""
self.fail: NodeNG | None = None # can be None
"""The message shown when the assertion fails.""" An A symptom of the problem is the frequent appearance of Now, the reason AFAICT that these fields are all marked as optional is that the type annotations are declared in |
#2061 is a concrete example of the kind of change I'm talking about. |
This is exactly why. When I was first defining the types of everything all the way back when I added docstrings to everything, I had to make everything optional because of how
We'd risk the potential for some of the attributes to be accidentally left unset by the Personally I'd want to be looking to eliminate the |
astroid is very dynamic and very hard to type. A lot of effort went into typing it, and mypy is still not activated (#1287). It prevents automated error detection in pylint and it prevent most performance possibility that always start with proper typing, be it mypyc, a partial rewrite in a rust crate (#2014) or cython.
I'm opening this discussion so we can discuss the breaking changes we need to do to make it easier to type astroid in the future.
The text was updated successfully, but these errors were encountered: