-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
sthagen/python-mypy
#54Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
When I was trying to use stubgen to generate pyi for the PyAV package, an error is being thrown.
File "mypy\stubgenc.py", line 315, in generate_c_type_stub
TypeError: unbound method type.mro() needs an argument
After a bit investigation in stubgenc.py and PyAV. I found the issue is caused by these
https://github.com/python/mypy/blob/master/mypy/stubgenc.py#L299
https://github.com/python/mypy/blob/master/mypy/stubgenc.py#L355
Basically, when invoking obj.mro()
with EnumType
defined in https://github.com/PyAV-Org/PyAV/blob/main/av/enum.pyx#L25, it resolves into <type>.mro()
and complains missing argument, because EnumType
inherits type
.
The minimum case of this would just be python -c 'type.mro()'
To Reproduce
- Install PyAV with
pip install av
I am using 8.0.3 but most versions should work though - Install mypy with
pip install mypy
I am using 0.812 but most versions withstubgen
should behave similar - Run command
stubgen -p av
or more specificallystubgen -m av.enum
Expected Behavior
It supposed to generate pyi
file without throwing errors
Actual Behavior
PS C:\Users\Gen\Repos> stubgen -m av.enum
Traceback (most recent call last):
File "c:\users\gen\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\gen\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Gen\AppData\Local\Programs\Python\Python39\Scripts\stubgen.exe\__main__.py", line 7, in <module>
File "mypy\stubgen.py", line 1582, in main
File "mypy\stubgen.py", line 1475, in generate_stubs
File "mypy\stubgenc.py", line 64, in generate_stub_for_c_module
File "mypy\stubgenc.py", line 315, in generate_c_type_stub
TypeError: unbound method type.mro() needs an argument
Your Environment
- Mypy version used: 0.812
- Mypy command-line flags:
stubgen -m av.enum
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.9.1
- Operating system and version: Windows 10 Pro 19042.804
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong