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

ValueError: column parameter (xxx) is not in a valid range (yyy-zzz) #35

Open
williballenthin opened this issue Jul 13, 2023 · 1 comment
Assignees
Labels
bug Something isn't working stale

Comments

@williballenthin
Copy link

Description

When linting a file that contains a specific statement split across multiple lines, flake8-encodings raises a ValueError.

Steps to Reproduce

linting the following file:

subprocess.run(
    "date"
).stdout.strip()

Actual result:

❯ flake8 scripts/repro.py
Traceback (most recent call last):
  File "/home/user/code-personal/capa/.direnv/python-3.11/bin/flake8", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/main/cli.py", line 23, in main
    app.run(argv)
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/main/application.py", line 198, in run
    self._run(argv)
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/main/application.py", line 187, in _run
    self.run_checks()
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/main/application.py", line 103, in run_checks
    self.file_checker_manager.run()
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/checker.py", line 236, in run
    self.run_serial()
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/checker.py", line 214, in run_serial
    self.results = [
                   ^
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/checker.py", line 219, in <listcomp>
    ).run_checks()
      ^^^^^^^^^^^^
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/checker.py", line 524, in run_checks
    self.run_ast_checks()
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8/checker.py", line 426, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8_encodings/__init__.py", line 363, in run
    class_visitor.first_visit(self._tree, self.filename)
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8_encodings/__init__.py", line 213, in first_visit
    self.visit(node)
  File "/nix/store/ss7212zavvshj2wv7s4sr8np68j3ij9d-devshell-dir/lib/python3.11/ast.py", line 410, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/nix/store/ss7212zavvshj2wv7s4sr8np68j3ij9d-devshell-dir/lib/python3.11/ast.py", line 418, in generic_visit
    self.visit(item)
  File "/nix/store/ss7212zavvshj2wv7s4sr8np68j3ij9d-devshell-dir/lib/python3.11/ast.py", line 410, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/nix/store/ss7212zavvshj2wv7s4sr8np68j3ij9d-devshell-dir/lib/python3.11/ast.py", line 420, in generic_visit
    self.visit(value)
  File "/nix/store/ss7212zavvshj2wv7s4sr8np68j3ij9d-devshell-dir/lib/python3.11/ast.py", line 410, in visit
    return visitor(node)
           ^^^^^^^^^^^^^
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8_encodings/__init__.py", line 319, in visit_Call
    inferred_types = get_inferred_types(self.jedi_script, node)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/flake8_encodings/__init__.py", line 433, in get_inferred_types
    for inferred_name in jedi_script.infer(node.lineno, node.func.col_offset + len('.'.join(attr_names[:-1]))):
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/code-personal/capa/.direnv/python-3.11/lib/python3.11/site-packages/jedi/api/helpers.py", line 484, in wrapper
    raise ValueError('`column` parameter (%d) is not in a valid range '
ValueError: `column` parameter (21) is not in a valid range (0-15) for line 1 ('subprocess.run(\n').

Expected result:

no stack trace.

Reproduces how often:

easily reproduced

Version

❯ python --version
Python 3.11.0

❯ pip freeze | grep flake8-encodings
flake8-encodings==0.5.0.post1

Installation source

pip

Other Additional Information:

the following script does not raise an exception, suggesting that perhaps the linter is relying on assumptions about some AST nodes being found on a single line:

subprocess.run("date").stdout.strip()
@LukasWestholt
Copy link

LukasWestholt commented Dec 7, 2023

I have the same problem! Using 0.5.0.post1

@stale stale bot added the stale label Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants