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

Usage error when using --find-occurrences #15527

Closed
JeroenSchmidt opened this issue Jun 27, 2023 · 6 comments · Fixed by #15528
Closed

Usage error when using --find-occurrences #15527

JeroenSchmidt opened this issue Jun 27, 2023 · 6 comments · Fixed by #15528
Labels
bug mypy got something wrong

Comments

@JeroenSchmidt
Copy link

JeroenSchmidt commented Jun 27, 2023

Hi All,
I am trying to use --find-occurrences but it looks like it might be broken.
I could also be reading --help wrong; in that case it would help if there was clear documentation on how to use it - related #2042

Commands tried:

python -m mypy <path_to_project>/some_module.py --find-occurrences Example.ClassName
python -m mypy <path_to_project>/some_module.py --find-occurrences "(Example.ClassName)"
python -m mypy <path_to_project>/some_module.py --find-occurrences "(Example,ClassName)"
python -m mypy <path_to_project>/some_module.py --find-occurrences

Output

Traceback (most recent call last):
  File "/Users/user/miniconda3/envs/bkng-data-lineage2/lib/python3.10/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/user/miniconda3/envs/bkng-data-lineage2/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/user/miniconda3/envs/bkng-data-lineage2/lib/python3.10/site-packages/mypy/__main__.py", line 37, in <module>
    console_entry()
  File "/Users/user/miniconda3/envs/bkng-data-lineage2/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
    main()
  File "mypy/main.py", line 66, in main
  File "mypy/main.py", line 1335, in process_options
TypeError: tuple[str, str] or None object expected; got list

Your Environment

  • Mypy version used: mypy==1.4.1, mypy-extensions==1.0.0, pylsp-mypy==0.6.7
  • Mypy configuration options: None
  • Python version used: 3.10
@JeroenSchmidt JeroenSchmidt added the bug mypy got something wrong label Jun 27, 2023
@hauntsaninja
Copy link
Collaborator

Oh interesting, I didn't know this was an option. Looks like it's documented as experimental. Anyway easy enough to fix...

@hauntsaninja
Copy link
Collaborator

As a workaround, you could probably install mypy without mypyc, e.g. via pip install --no-binary mypy (note: this version of mypy will be significantly slower than the usual one)

hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Jun 27, 2023
Fixes python#15527

Namespaces are untyped, so this only gets caught by mypyc.

I didn't know about this feature, looks like it's explicitly documented
as experimental. Guess no one has used it in a long, long time.
@JeroenSchmidt
Copy link
Author

Thanks @hauntsaninja I'll try the work around.
To anyone else reading this you need to run pip install --no-binary mypy mypy - the command above doesn't work

@JeroenSchmidt
Copy link
Author

@hauntsaninja it might be out of scope for this bug report but I noticed that --find-occurrences silently does nothing if a .mypy_cache exists. The solution is to remove it before every time running --find-occurrences.

@hauntsaninja
Copy link
Collaborator

A slightly more ergonomic workaround would be to pass --no-incremental to mypy. I'm not planning on fixing that, but you might be able to make a PR to fix? Likely just setting options.incremental = False in the right place would fix.

@JeroenSchmidt
Copy link
Author

@hauntsaninja will do. Thank you for the help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants