Skip to content
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

[mypyc] Fix ParamSpec #17309

Merged
merged 3 commits into from
Jun 3, 2024
Merged

[mypyc] Fix ParamSpec #17309

merged 3 commits into from
Jun 3, 2024

Conversation

hauntsaninja
Copy link
Collaborator

mypyc/irbuild/mapper.py Outdated Show resolved Hide resolved
@AlexWaygood
Copy link
Member

Looks like TypeVarTuple might also not be handled — worth adding that too?

@kai3341
Copy link

kai3341 commented Jun 1, 2024

I've install mypy directly from this branch to test on my code and found it throws different error now:

Traceback (most recent call last):
  File "/home/kai/Projects/ovpn-mgmt/build/setup.py", line 5, in <module>
    ext_modules=mypycify(['./ovpn-mgmt.py'], opt_level="3", debug_level="1"),
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/build.py", line 525, in mypycify
    groups, group_cfilenames = mypyc_build(
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/build.py", line 435, in mypyc_build
    group_cfiles, ops_text = generate_c(
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/build.py", line 243, in generate_c
    modules, ctext = emitmodule.compile_modules_to_c(
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/codegen/emitmodule.py", line 428, in compile_modules_to_c
    modules = compile_modules_to_ir(result, mapper, compiler_options, errors)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/codegen/emitmodule.py", line 272, in compile_modules_to_ir
    scc_ir = compile_scc_to_ir(trees, result, mapper, compiler_options, errors)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/codegen/emitmodule.py", line 227, in compile_scc_to_ir
    modules = build_ir(scc, result.graph, result.types, mapper, compiler_options, errors)
  File "/usr/lib/python3.11/contextlib.py", line 81, in inner
    return func(*args, **kwds)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/main.py", line 95, in build_ir
    transform_mypy_file(builder, module)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/main.py", line 140, in transform_mypy_file
    builder.accept(node)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/builder.py", line 266, in accept
    node.accept(self.visitor)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypy/nodes.py", line 1181, in accept
    return visitor.visit_class_def(self)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/visitor.py", line 168, in visit_class_def
    transform_class_def(self.builder, cdef)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/classdef.py", line 138, in transform_class_def
    cls_builder.add_method(get_func_def(stmt))
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/classdef.py", line 270, in add_method
    handle_ext_method(self.builder, self.cdef, fdef)
  File "/home/kai/Projects/ovpn-mgmt/.venv/lib/python3.11/site-packages/mypyc/irbuild/function.py", line 458, in handle_ext_method
    class_ir.method_decls[name].sig, base.method_decls[name].sig
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^
ovpn-mgmt.py:1161: KeyError: 'handle1234567'

I've just renamed my method handle to handle1234567 to be sure why does mypyc throws an exception.

So, what should I do to help you? Is is separated issue or this issue continuation? I'll try to minimize the code to reproduce this issue

It's funny thing this method handle1234567 accepts only self arg. And returns None. But decorated with my class-instance decorator. Maybe it's really separated issue

@hauntsaninja
Copy link
Collaborator Author

hauntsaninja commented Jun 1, 2024

Sounds like a separate issue, searching stacktrace sounds similar to mypyc/mypyc#767. The best way to help is to open a PR, I don't have time to look into it myself (and in general I don't really know much about mypyc)

@JukkaL JukkaL merged commit aa4410f into python:master Jun 3, 2024
13 checks passed
@hauntsaninja hauntsaninja deleted the mypyc-param branch September 20, 2024 05:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AssertionError: unexpected type <class 'mypy.types.ParamSpecType'>
4 participants