Skip to content

mypy INTERNAL ERROR #459

@WhyNotHugo

Description

@WhyNotHugo

Bug report

mypy crashes with an internal error.
Removing this plugin makes mypy pass, so I'm under the impression there's something with the plugin that makes it fail.

Do let me know if this should actually be reported to mypy.

➜ tox -e mypy
GLOB sdist-make: /home/hugo/workspace/Hugo/django-afip/setup.py
mypy inst-nodeps: /home/hugo/workspace/Hugo/django-afip/.tox/.tmp/package/1/django-afip-7.1.0.post57+g40a65e2.d20200910.zip
mypy installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,cached-property==1.5.1,cairocffi==1.1.0,CairoSVG==2.4.2,certifi==2020.6.20,cffi==1.14.2,chardet==3.0.4,cryptography==3.0,cssselect2==0.3.0,defusedxml==0.6.0,dj-database-url==0.5.0,Django==3.1,django-afip==7.1.0.post57+g40a65e2.d20200910,django-renderpdf==2.0.1,django-stubs==1.5.0,html5lib==1.1,idna==2.10,isodate==0.6.0,lxml==4.5.2,mypy==0.770,mypy-extensions==0.4.3,Pillow==7.2.0,pycparser==2.20,pyOpenSSL==19.1.0,Pyphen==0.9.5,python-barcode==0.13.1,pytz==2020.1,requests==2.24.0,requests-toolbelt==0.9.1,setuptools-git==1.2,setuptools-scm==4.1.2,six==1.15.0,sqlparse==0.3.1,tinycss2==1.0.2,typed-ast==1.4.1,typing-extensions==3.7.4.3,urllib3==1.25.10,WeasyPrint==51,webencodings==0.5.1,zeep==3.4.0
mypy run-test-pre: PYTHONHASHSEED='852022991'
mypy run-test: commands[0] | mypy --show-traceback --pdb django_afip/admin.py
django_afip/models.py:182: error: INTERNAL ERROR -- Please try using mypy master on Github:
https://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 0.770
Dropping into pdb
> /home/hugo/workspace/Hugo/django-afip/.tox/mypy/lib/python3.8/site-packages/mypy_django_plugin/lib/helpers.py(355)copy_method_to_another_class()
-> assert bound_arg_type is not None
(Pdb) l
350  	
351  	    for arg_name, arg_type, original_argument in zip(method_type.arg_names[1:],
352  	                                                     method_type.arg_types[1:],
353  	                                                     method_node.arguments[1:]):
354  	        bound_arg_type = semanal_api.anal_type(arg_type, allow_placeholder=True)
355  ->	        assert bound_arg_type is not None
356  	
357  	        if isinstance(bound_arg_type, PlaceholderNode):
358  	            return
359  	
360  	        var = Var(name=original_argument.variable.name,
(Pdb) a
ctx = ClassDefContext(cls=<mypy.nodes.ClassDef object at 0x7f7b7291a720>, reason=<mypy.nodes.NameExpr object at 0x7f7b7a074120>, api=<mypy.semanal.SemanticAnalyzer object at 0x7f7b7515e320>)
self_type = django_afip.models.ReceiptType_GenericAfipTypeManager[django_afip.models.ReceiptType]
new_method_name = 'populate'
method_node = <mypy.nodes.FuncDef object at 0x7f7b74d72100>
(Pdb) arg_name, arg_type, original_argument
('ticket', AuthTicket?, <mypy.nodes.Argument object at 0x7f7b74d7b9a0>)
(Pdb)

What's wrong

Here's a link to my code for the exact version that fails. You can reproduce the failure by cloning the repository and running tox -e mypy.

The line where mypy crashes simply has a model, which extends an abstract model. There's a few fields, but nothing special about it. I'm inclined to believe the issue is not specifically with this class but something else.

How is that should be

It shouldn't crash.

System information

  • OS: ArchLinux
  • python version: 3.8.5
  • django version: 3.1
  • mypy version: v0.782, but also tried master
  • django-stubs version: 1.5.0

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcrash"Internal error" crashes from mypymypy-pluginIssues specific to mypy_django_plugin

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions