Skip to content

Commit

Permalink
fix: Do not detect as requirements.txt if the file is a python script
Browse files Browse the repository at this point in the history
Close #2416

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed Nov 22, 2023
1 parent 3eddfbc commit a339412
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/2416.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Do not detect as requirements.txt if the file is a python script.
6 changes: 4 additions & 2 deletions src/pdm/formats/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import hashlib
import shlex
import urllib.parse
from pathlib import Path
from typing import TYPE_CHECKING, Any, Mapping

from pdm.formats.base import make_array
Expand Down Expand Up @@ -98,8 +99,9 @@ def check_fingerprint(project: Project, filename: PathLike) -> bool:
try:
tomllib.load(fp)
except ValueError:
# the file should be a requirements.txt if it not a TOML document.
return True
# the file should be a requirements.txt
# if it's not a TOML document nor py script.
return Path(filename).suffix not in (".py",)
else:
return False

Expand Down

0 comments on commit a339412

Please sign in to comment.