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

Tech Debt: Cleanup should_warn and rely on extend-select (+ maybe delete load_file) #260

Open
asottile opened this issue Jun 10, 2022 · 2 comments · Fixed by #261
Open

Comments

@asottile
Copy link
Member

minimal reproduction (trigger any B9* warning with the default settings)

$ rm -rf venv && virtualenv -qq venv && venv/bin/pip install -qq git+https://github.com/pycqa/flake8 git+https://github.com/pycqa/flake8-bugbear && venv/bin/flake8 --config /dev/null - <<< $'class C:\n    def __init__(wat): ...'
Traceback (most recent call last):
  File "venv/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/main/application.py", line 336, in run
    self._run(argv)
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/main/application.py", line 325, in _run
    self.run_checks()
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/main/application.py", line 229, in run_checks
    self.file_checker_manager.run()
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/checker.py", line 252, in run
    self.run_serial()
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/checker.py", line 237, in run_serial
    checker.run_checks()
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/checker.py", line 531, in run_checks
    self.run_ast_checks()
  File "/tmp/y/venv/lib/python3.8/site-packages/flake8/checker.py", line 435, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/tmp/y/venv/lib/python3.8/site-packages/bugbear.py", line 61, in run
    if self.should_warn(e.message[:4]):
  File "/tmp/y/venv/lib/python3.8/site-packages/bugbear.py", line 158, in should_warn
    if code[:i] in self.options.select:
TypeError: argument of type 'NoneType' is not iterable

looking at the code, you should be able to delete should_warn entirely and rely on extend-select (and delete load_file while you're at it!)

@sco1
Copy link
Contributor

sco1 commented Jun 10, 2022

This has also popped up in #221

@cooperlees cooperlees reopened this Jun 23, 2022
@cooperlees cooperlees changed the title should_warn is incompatible with flake8 (next) Tech Debt: Cleanup should_warn and rely on extend-select (+ maybe delete load_file) Jun 23, 2022
@rabelux
Copy link

rabelux commented Jan 10, 2023

+1, I'm also getting TypeError: argument of type 'NoneType' is not iterable

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

Successfully merging a pull request may close this issue.

4 participants