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

Packages having a name starting with "http" are interpreted as URL and incorrrectly parsed from requirements.txt #539

Closed
mmtevelde opened this issue Dec 21, 2023 · 0 comments · Fixed by #570
Labels
bug Something isn't working

Comments

@mmtevelde
Copy link

Describe the bug

My project uses requirements.txt to define dependencies. We use the httpx library. When running deptry, it incorrectly parses this entry as a dependency specified from URL:

$ grep httpx requirements.txt
httpx==0.25.2
$ pre-commit run --all-files
Could not parse dependency name from url httpx==0.25.2

The dependency parser incorrectly interprets the line as containing a URL.

Subsequently it throws a DEP003 because the dependency is imported but not detected as being specified in the requirements.txt (even though it is there): sample.py:1:0: DEP003 'httpx' imported but it is a transitive dependency.

As a workaround, I have added an ignore to my pyproject.toml:

[tool.deptry.per_rule_ignores]
DEP003 = ["httpx"]

I think a fix would be to improve the _line_is_url function or its regex here
Maybe changing the matcher from http|https to http://|https:// would fix the problem without impacting the intended functionality.

To Reproduce

Steps to reproduce the behavior:

  1. Specify requirements.txt dependency starting with http
  2. Optional - Import this dependency somewhere in your code
  3. Run deptry

Expected behavior

System [please complete the following information]:

  • OS: macOS Sonoma
  • Language Version: Python 3.11
  • Poetry version: N/A, using pip

Additional context

N/A

@mmtevelde mmtevelde added the bug Something isn't working label Dec 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant