Skip to content

Commit

Permalink
Fix linting errors due to updated requirements pkg.name being optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
drewsilcock committed Feb 7, 2025
1 parent 78c2054 commit 7c42c8f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions hooks/check_missing_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import subprocess
import sys
from pathlib import Path
from typing import List
from typing import List, Optional

import requirements

from .utils import Hook


def _parse_package_name(name: str) -> str:
def _parse_package_name(name: Optional[str]) -> Optional[str]:
"""
Force lower case and replace underscore with dash to compare environment
packages (see https://www.python.org/dev/peps/pep-0426/#name)
Expand All @@ -22,7 +22,7 @@ def _parse_package_name(name: str) -> str:
Returns:
Formatted package name
"""
return name.lower().replace("_", "-")
return name.lower().replace("_", "-") if name else None


def _get_installed_packages() -> List[str]:
Expand All @@ -33,7 +33,7 @@ def _get_installed_packages() -> List[str]:
Returns:
List of formatted names of installed packages
"""
return [
package_names = [
_parse_package_name(req.name)
for req in requirements.parse(
subprocess.check_output(
Expand All @@ -42,6 +42,8 @@ def _get_installed_packages() -> List[str]:
)
]

return [name for name in package_names if name]


def _get_required_packages(filepath: str) -> List[str]:
"""
Expand Down

0 comments on commit 7c42c8f

Please sign in to comment.