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: 'list' object has no attribute 'split' #11851

Closed
Torxed opened this issue Dec 27, 2021 · 5 comments
Closed

AttributeError: 'list' object has no attribute 'split' #11851

Torxed opened this issue Dec 27, 2021 · 5 comments
Labels

Comments

@Torxed
Copy link

Torxed commented Dec 27, 2021

Crash Report

I suspect this is another one for #10201.
Mainly because I'm using Python v3.10.1 and this worked a few versions ago.
While running a github workflow, mypy crashes using mypy --module x --strict.

Traceback

This traceback is from the .github workflow execution:

Run mypy --strict --module ourkvm
Traceback (most recent call last):
  File "/usr/sbin/mypy", line 33, in <module>
    sys.exit(load_entry_point('mypy==0.930', 'console_scripts', 'mypy')())
  File "/usr/lib/python3.10/site-packages/mypy/__main__.py", line 12, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "/usr/lib/python3.10/site-packages/mypy/main.py", line 70, in main
    sources, options = process_options(args, stdout=stdout, stderr=stderr,
  File "/usr/lib/python3.10/site-packages/mypy/main.py", line 919, in process_options
    parse_config_file(options, set_strict_flags, config_file, stdout, stderr)
  File "/usr/lib/python3.10/site-packages/mypy/config_parser.py", line 207, in parse_config_file
    updates, report_dirs = parse_section(
  File "/usr/lib/python3.10/site-packages/mypy/config_parser.py", line 400, in parse_section
    v = ct(section.get(key))
  File "/usr/lib/python3.10/site-packages/mypy/config_parser.py", line 129, in <lambda>
    'exclude': lambda s: [p.strip() for p in s.split('\n') if p.strip()],
AttributeError: 'list' object has no attribute 'split'
Error: Process completed with exit code 1.

To Reproduce

This is the following workflow file I'm using:

on: [ push, pull_request ]
name: mypy type checking
jobs:
    mypy:
        runs-on: ubuntu-latest
        container:
            image: archlinux:latest
        steps:
            - uses: actions/checkout@v2
            - run: pacman --noconfirm -Syu python mypy python-pip
            - run: python -m pip install --upgrade pip
            - run: pip install fastapi pydantic
            - name: run mypy
              run: python --version
              run: mypy --version
              run: mypy --strict --module ourkvm

Your Environment

  • Mypy version used: 0.930 (v0.910 worked)
  • Mypy command-line flags: -m project --strict
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
python_version = "3.10"
exclude = ["tests/", "test.py"]

[[tool.mypy.overrides]]
module = "fastapi_resource_server.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "psutil.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "systemd.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "uvicorn.*"
ignore_missing_imports = true
  • Python version used: 3.10.1
  • Operating system and version: Arch Linux (latest)
@Torxed Torxed added the crash label Dec 27, 2021
@Torxed Torxed mentioned this issue Dec 27, 2021
21 tasks
@Torxed
Copy link
Author

Torxed commented Dec 27, 2021

Pretty convinced this is just exclude = ["tests/", "test.py"] not being supported any longer.
Been working great before and depending on which examples you find they tell you to specify this differently.

And using the mypy configuration syntax doesn't work either:

[tool.mypy]
python_version = "3.10"
exclude =
    ^tests\/$
    ^test\.py$

Until I figure out what the new syntax should be.
I can work around it with exclude = "tests" and that avoids the test folder at least.

@A5rocks
Copy link
Contributor

A5rocks commented Dec 28, 2021

For what it's worth, you may wish to follow the progress of #11828 (Though it looks like you want a multiline string for 0.930)

@Torxed
Copy link
Author

Torxed commented Dec 28, 2021

Yepp that looks like it will bring back the list support for exclude.
Thank, subscribed.

@Amund211
Copy link

Amund211 commented Jan 9, 2022

Ran into this myself. As @A5rocks said, this is fixed by #11828, which is now released in 0.931 as of Jan. 7.

Amund211 added a commit to Amund211/prism that referenced this issue Jan 9, 2022
Pin mypy to at least current version due to a bug:
python/mypy#11851
@hauntsaninja
Copy link
Collaborator

Yup, the solution here is using 0.931

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

No branches or pull requests

4 participants