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

1.7.0 regression with mypyc #16480

Closed
mr-c opened this issue Nov 13, 2023 · 3 comments · Fixed by #16484
Closed

1.7.0 regression with mypyc #16480

mr-c opened this issue Nov 13, 2023 · 3 comments · Fixed by #16484
Labels
bug mypy got something wrong topic-mypyc mypyc bugs

Comments

@mr-c
Copy link
Contributor

mr-c commented Nov 13, 2023

Bug Report

Bisected to e1f6d6b from #16268

To Reproduce

git clone https://github.com/common-workflow-language/cwltool
cd cwltool
git checkout dependabot/pip/mypy-1.7.0
make dev
MYPYPATH=mypy-stubs CWLTOOL_USE_MYPYC=1 pip install --verbose -e .
pytest -k '(test_listing_deep or test_cwltool_options or test_passthrough_successive or test_listing_v1_0 or test_disable_dir_overwrite_without_ext or test_disable_dir_creation_in_outdir_with_ext or test_warn_large_inputs or test_directory_workflow)'
# any of these tests will trigger the error, I'm just being comprehensive

Expected Behavior

Tests pass without failure

Actual Behavior

ERROR    cwltool:test_ext.py:30 Got workflow error
Traceback (most recent call last):
  File "cwltool/executors.py", line 220, in run_jobs
    for job in jobiter:
  File "cwltool/command_line_tool.py", line 963, in job
    builder = self._init_job(job_order, runtimeContext)
  File "cwltool/process.py", line 788, in _init_job
    visit_class(v, ("Directory",), lambda x: inc(dircount))  # noqa: B023
  File "cwltool/utils.py", line 219, in visit_class
    op(rec)
  File "cwltool/process.py", line 788, in <lambda>
    visit_class(v, ("Directory",), lambda x: inc(dircount))  # noqa: B023
AttributeError: attribute 'inc' of '_init_job_Process_env' undefined
ERROR    cwltool:test_ext.py:30 Workflow error, try again with --debug for more information:
attribute 'inc' of '_init_job_Process_env' undefined

Your Environment

  • Mypy version used: 1.7.0
  • Mypy command-line flags:
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.11.2, but also 3.8, 3.9, 3.11, and 3.12
@mr-c mr-c added the bug mypy got something wrong label Nov 13, 2023
@AlexWaygood AlexWaygood added the topic-mypyc mypyc bugs label Nov 13, 2023
@AlexWaygood
Copy link
Member

Bisected to e1f6d6b from #16268

cc. @JukkaL

@ilevkivskyi
Copy link
Member

A standalone mypyc test case to reproduce

[case testCallNestedFunctionWithLambda]
def f(x: int) -> int:
    def inc(x: int) -> int:
        return x + 1
    return (lambda x: inc(x))(1)
[file driver.py]
from native import f
print(f(1))
[out]
2

Fails with

Traceback (most recent call last):
  File "driver.py", line 2, in <module>
    print(f(1))
          ^^^^
  File "run-functions.test", line 1294, in f
    return (lambda x: inc(x))(1)
  File "run-functions.test", line 1294, in <lambda>
    return (lambda x: inc(x))(1)
AttributeError: attribute 'inc' of 'f_env' undefined

@ilevkivskyi
Copy link
Member

ilevkivskyi commented Nov 13, 2023

Also same crash in a test that doesn't involve a lambda:

[case testCallNestedFunctionWithoutLambda]
def f() -> None:
    def a() -> None:
        pass
    def b() -> None:
        a()
    b()
[file driver.py]
from native import f
f()

ilevkivskyi added a commit that referenced this issue Nov 16, 2023
Fixes #16480

Fix is straightforward, but also suspicious, since I am not sure how it
ever worked without this.
JukkaL pushed a commit that referenced this issue Nov 22, 2023
Fixes #16480

Fix is straightforward, but also suspicious, since I am not sure how it
ever worked without this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-mypyc mypyc bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants