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

requirements-txt-fixer doesn't support comments with indent #548

Closed
greshilov opened this issue Jan 17, 2021 · 5 comments
Closed

requirements-txt-fixer doesn't support comments with indent #548

greshilov opened this issue Jan 17, 2021 · 5 comments

Comments

@greshilov
Copy link
Contributor

Consider following example requirements.txt file:

# This comment is fine
a==0.0.1
    #   This comment is not fine
b==0.0.2
# This comment is fine too

Script requirements_txt_fixer.py will fail with AssertionError on line # This comment is not fine.

@asottile
Copy link
Member

I kind of agree with the assertion error -- why is that indented?

@greshilov
Copy link
Contributor Author

greshilov commented Jan 17, 2021

I kind of agree with the assertion error -- why is that indented?

it doesn't violate the rules. For example pip-compile tool from pip-tools package generates files with following structure:

#
# This file is autogenerated by pip-compile
# To update, run:
#
#    pip-compile --allow-unsafe requirements/dev.in
#
aiodns==2.0.0 ; sys_platform == "linux" or sys_platform == "darwin" and python_version >= "3.7"
    # via -r requirements/base.txt
aiohttp-theme==0.1.6
    # via
    #   flake8-pyi
    #   pytest
babel==2.9.0
...

@asottile
Copy link
Member

if you're using pip-tools there's no reason to use this hook (as it sorts)

@greshilov
Copy link
Contributor Author

if you're using pip-tools there's no reason to use this hook (as it sorts)

Agree.
But it shows that some developers may use indents before comments (it's just a matter of taste).

pip itself is ok with indented comments, so why this tool is not?

@asottile
Copy link
Member

pip itself is ok with indented comments, so why this tool is not?

pip is also ok with unsorted requirements files -- this tool implements a very specific style decision

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

No branches or pull requests

2 participants