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 ordering breaks using --index-url and --extra-index-url together in requirements.txt #612

Open
redfungus opened this issue Jun 14, 2021 · 8 comments

Comments

@redfungus
Copy link

If you use both the --index-url and --extra-index-url flags together in a requirements.txt file the hook will put --extra-index-url above the --index-url which causes the url set to index-url be skipped. I suppose this is because the flags are also sorted alphabetically.

@asottile
Copy link
Member

note that --extra-index-url is unsafe and should generally never be used

a special case could be added, though my thought is that supporting something that shouldn't be used seems like unnecessary work

@redfungus
Copy link
Author

@asottile I did not know about the security problems! Thank you for the link!

@robin-snt
Copy link

robin-snt commented Jun 21, 2022

Is there a pre-commit hook for detecting if the developer has incorrectly configured pip to run with --extra-index-url instead of --index-url?

I mean in addition to simply reading the requirements files, so it would also detect if the global pip config has been incorrectly configured?

@asottile
Copy link
Member

something like that doesn't really make sense as a hook -- looking at global settings doesn't make sense for something that's supposed to check source code

plus you'd have to know to configure such a thing and at that point you might as well just turn off the bad setting -- it's not something you're going to "accidentally" commit one day

@robin-snt
Copy link

@asottile Your insight is highly appreciated!

@renegaderyu
Copy link

@asottile please review if you have time. I'm hoping this PR is simple enough and goes with the spirit of the special case you mentioned. Also, I'd appreciate if you could label w/ hacktoberfest-accepted so I can get a tree planted, thanks.

@asottile
Copy link
Member

I'm not going to review something which doesn't pass tests

@renegaderyu
Copy link

@asottile Apologies for not seeing the failing tests before asking. I think its ready now.

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

Successfully merging a pull request may close this issue.

4 participants