8000 [Python forward compat] click.types.Path.covert: BytesWarning: Comparison between bytes and string · Issue #2877 · pallets/click · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Python forward compat] click.types.Path.covert: BytesWarning: Comparison between bytes and string #2877

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

Open
webknjaz opened this issue Apr 3, 2025 · 1 comment

Comments

@webknjaz
Copy link
webknjaz commented Apr 3, 2025

So I've hit this through pip-tools' pip-compile executable some time ago but forgot to report immediately.

I tend to run Python with strictness like python -I -s -E -bb -Werror -m piptools compile --some --args. And that's how I've found this warning. I imagine, it's easy to address by changing the check here: https://github.com/pallets/click/blob/c9f7d9d/src/click/types.py#L929C64-L929C75. Perhaps, by converting the data type.

Here's a minimal repro. In needs a modern enough Python for -bb IIRC.

$ python -Im pip install Click
$ python -bb -Werror
Python 3.12.9 (main, Feb 22 2025, 21:46:24) [GCC 14.2.1 20241221] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from click.types import Path
>>> Path(allow_dash=True).convert('', '', '')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/path/to/venv/lib/python3.12/site-packages/click/types.py", line 865, in convert
    is_dash = self.file_okay and self.allow_dash and rv in (b"-", "-")
                                                     ^^^^^^^^^^^^^^^^^
BytesWarning: Comparison between bytes and string

Environment:

  • Python version: 3.12.9
  • Click version: 8.1.8
@webknjaz
Copy link
Author
webknjaz commented Apr 3, 2025

@davidism may I ask you to label this as a good first issue?

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

No branches or pull requests

1 participant
0