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

AttributeError when mypy.ini contains disabled_error_codes #16002

Closed
cebtenzzre opened this issue Aug 30, 2023 · 1 comment · Fixed by #16005
Closed

AttributeError when mypy.ini contains disabled_error_codes #16002

cebtenzzre opened this issue Aug 30, 2023 · 1 comment · Fixed by #16005
Labels
crash topic-configuration Configuration files and flags

Comments

@cebtenzzre
Copy link

cebtenzzre commented Aug 30, 2023

Crash Report

mypy crashes if disabled_error_codes is in mypy.ini.

Traceback

Traceback (most recent call last):
  File "<stdin>", line 4, in <module>
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/home/cebtenzzre/src/forks/mypy/mypy/__main__.py", line 37, in <module>
    console_entry()
  File "/home/cebtenzzre/src/forks/mypy/mypy/__main__.py", line 15, in console_entry
    main()
  File "/home/cebtenzzre/src/forks/mypy/mypy/main.py", line 99, in main
    res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/main.py", line 178, in run_build
    res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 189, in build
    result = _build(
             ^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 262, in _build
    graph = dispatch(sources, manager, stdout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 2938, in dispatch
    process_graph(graph, manager)
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 3336, in process_graph
    process_stale_scc(graph, scc, manager)
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 3459, in process_stale_scc
    graph[id].write_cache()
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 2499, in write_cache
    new_interface_hash, self.meta = write_cache(
                                    ^^^^^^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/build.py", line 1627, in write_cache
    "options": options.select_options_affecting_cache(),
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/options.py", line 545, in select_options_affecting_cache
    val = sorted([code.code for code in val])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cebtenzzre/src/forks/mypy/mypy/options.py", line 545, in <listcomp>
    val = sorted([code.code for code in val])
                  ^^^^^^^^^
AttributeError: 'str' object has no attribute 'code'. Did you mean: 'encode'?

To Reproduce

  1. Create repr.py containing anything (I put pass)
  2. Create this mypy.ini:
[mypy]
disabled_error_codes = import-untyped
  1. Run mypy repr.py

Your Environment

  • Mypy version used: mypy 1.7.0+dev.9a0aca14724eeef580eefcd3b340678313a1930a (compiled: no)
  • Python version used: Python 3.11.3
  • Operating system and version: Arch Linux
@hauntsaninja
Copy link
Collaborator

Oh lol, the option name is "disable_error_code", but because of annoying reasons mypy's config parsing sort of accepts the other phrasing. Easy to fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash topic-configuration Configuration files and flags
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants