-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Crash on latest Django Project with dmypy #11456
Comments
Please, report it in our repo: https://github.com/typeddjango/django-stubs/ Also:
Thanks! |
@sobolevn I will try. Sadly, could only reproduce it on a fresh repo ones, and then it went away. For our project tho, it never goes away, does not matter which version combination i would take with stubs and mypy :( Ima try to pick it out of our giant repo. |
Having the same problem here, it started with a |
@Thorbenl Any chance you have aiohttp as a dependency? I dropped into pdb and here's what I saw: (Pdb) lvalue.node.info
<TypeInfo aiohttp.http_parser.HttpParser> After bisecting the project history, it looks like aio-libs/aiohttp@a6c7f15 as the problematic commit. You can repro by creating [mypy]
cache_fine_grained = True
ignore_errors = True And running (Technically you don't have to run errors, but this lets you bisect automatically.) cc: @asvetlov |
Found the problem, although I'm not completely sure why it's a problem: - class HttpParser(abc.ABC):
+ class HttpParser(abc.ABC, Generic[_MsgT]): |
Full traceback:
|
Minimal repro! from typing import Generic, TypeVar
T = TypeVar('T', int, str)
class ExampleClass(Generic[T]):
def __init__(
self
) -> None:
self.example_attribute = None This seems to happen when:
🤯 |
Btw, this works fine: from typing import Generic, TypeVar
T = TypeVar('T', int, str)
class ExampleClass(Generic[T]):
def __init__(
self
) -> None:
... The problem reveals itself only if Great insight, thanks! |
Any ideas on how we might solve it? I haven't contributed to mypy, and honestly I'm not completely sure what purpose this |
It happens here:
I've never touched this part of mypy before. And these lines of code are quite old (4 years): Lines 487 to 493 in 43eecdb
This can either be:
|
@christianbundy this seems to remove the crash: if isinstance(lvalue.node, Var):
if lvalue.node.type:
lvalue_type = get_proper_type(lvalue.node.type)
else:
lvalue_type = NoneType() But, I am not sure it is correct though. Do you want to send a PR? We can work from there! |
Problem: When using the fine-grained cache, we raise an assertion in some situations when an attribute is defined as `None`. Solution: Remove truthiness check to ensure that `None` is an allowed type. Fixes: python#8682 Fixes: python#11456
Good idea, thank you! |
Problem: When using the fine-grained cache, we raise an assertion in some situations when an attribute is defined as `None`. Solution: Remove truthiness check to ensure that `None` is an allowed type. Fixes: python#8682 Fixes: python#11456
Bug Report
Canot run mypy on latest django, mypy and django-stubs version. started crashin after updating django from 3.2.8 to 3.2.9
Expected Behavior
normal typecheck run
Actual Behavior
crashes with:
(Write what happened.)
Your Environment
The text was updated successfully, but these errors were encountered: