PyCQA / flake8

flake8 is a python tool that glues together pycodestyle, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.
https://flake8.pycqa.org
Other
3.44k stars 307 forks source link

`UnicodeDecodeError` at parsing cli's arguments #1890

Closed yogrr closed 11 months ago

yogrr commented 11 months ago

how did you install flake8?

$ poetry install --no-root

unmodified output of flake8 --bug-report

{
"can't be reached": "parsing arguments is crashing"
}

describe the problem

what I expected to happen

To lintcheck my porject folder when launching flake8 under .venv by poetry

commands ran

$ flake8 (same output as underlying)
$ flake8 --bug-report
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "...\.venv\Scripts\flake8.exe\__main__.py", line 7, in <module>
  File "...\.venv\Lib\site-packages\flake8\main\cli.py", line 23, in main
    app.run(argv)
  File "...\.venv\Lib\site-packages\flake8\main\application.py", line 198, in run
    self._run(argv)
  File "...\.venv\Lib\site-packages\flake8\main\application.py", line 186, in _run
    self.initialize(argv)
  File "...\venv\Lib\site-packages\flake8\main\application.py", line 165, in initialize
    self.plugins, self.options = parse_args(argv)
                                 ^^^^^^^^^^^^^^^^
  File "...\.venv\Lib\site-packages\flake8\options\parse_args.py", line 62, in parse_args
    parse_options(
  File "...\.venv\Lib\site-packages\flake8_in_file_ignores\flake8_plugin.py", line 63, in parse_options
    pfi_noqa_strs = get_cwd_pfi_noqa()
                    ^^^^^^^^^^^^^^^^^^
  File "...\.venv\Lib\site-packages\flake8_in_file_ignores\flake8_plugin.py", line 32, in get_cwd_pfi_noqa
    first_line = read_first_line(file_path)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "...\venv\Lib\site-packages\flake8_in_file_ignores\flake8_plugin.py", line 19, in read_first_line
    first_line = f.readline().rstrip()
                 ^^^^^^^^^^^^
  File "C:\Users\admin\scoop\apps\pyenv\current\pyenv-win\versions\3.11.0b4\Lib\encodings\cp1251.py", line 23, in decode
    return codecs.charmap_decode(input,self.errors,decoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position 519: character maps to <undefined>
...

poetry's file

[build-system]
build-backend = "poetry.core.masonry.api"
requires = ["poetry-core"]

[tool.isort]
profile = "black"
line_length = 88
multi_line_output = 3
skip_gitignore = true
skip_glob = ["**/migrations/*", "**/settings/*"]
src_paths = ["./src/"]

[tool.mypy]
plugins = [
  "pydantic.mypy"
]

[tool.poetry]
...

[tool.poetry.dependencies]
aiopg = "^1.4.0"
fastapi = "^0.104.1"
fastapi-crudrouter = "^0.8.6"
peewee = "^3.17.0"
peewee-async = "^0.9.1"
poetry-plugin-dotenv = "^0.5.3"
python = "^3.11"
python-jose = {extras = ["cryptography"], version = "^3.3.0"}
python-multipart = "^0.0.6"
types-peewee = "^3.17.0.0"
uvicorn = "^0.24.0.post1"
passlib = "^1.7.4"
types-passlib = "^1.7.7.13"
pydantic = {extras = ["email"], version = "^2.5.1"}
pydantic-settings = "^2.1.0"
flake8-in-file-ignores = "^0.2.2"
bcrypt = "^4.0.1"
timespan = "^0.2.0"

[tool.poetry.group.dev.dependencies]
black = "^23.11.0"
flake8 = "^6.1.0"
isort = "^5.12.0"
mypy = "^1.7.0"
flake8-pyproject = "^1.2.3"

[[tool.mypy.overrides]]
module = [
  "fastapi_crudrouter.*",
  "fastapi_crudrouter.core._utils",
  "jose",
  "playhouse.*",
  "playhouse.shortcuts",
  "peewee_async",
]
ignore_missing_imports = true

[tool.flake8]
extend-ignore = [
  "E203",
  "E704",
]
per-file-ignores = [
  "__init__.py:F401",
]
max-line-length = 88
asottile commented 11 months ago

this is not us. read the file in the stacktrace where the error occurs and track down that plugin