Skip to content

Commit

Permalink
Clarify docstring for parsing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego authored and stijn committed Aug 16, 2022
1 parent d1240aa commit 6fb33ca
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/black/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ def parse_req_python_version(requires_python: str) -> Optional[TargetVersion]:
"""Parse a version string (i.e. ``"3.7"``) to a TargetVersion.
If parsing fails, will raise a packaging.version.InvalidVersion error.
If the parsed version cannot be mapped to a valid TargetVersion, returns None.
"""
version = Version(requires_python)
try:
Expand All @@ -179,6 +180,7 @@ def parse_req_python_specifier(requires_python: str) -> Optional[TargetVersion]:
"""Parse a specifier string (i.e. ``">=3.7,<3.10"``) to a TargetVersion.
If parsing fails, will raise a packaging.specifiers.InvalidSpecifier error.
If the parsed specifier cannot be mapped to a valid TargetVersion, returns None.
"""
if not requires_python:
return None
Expand Down

0 comments on commit 6fb33ca

Please sign in to comment.