fix: resolve CI linting failures
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-02 21:49:20 +00:00
parent 7922dccb80
commit 072a4c1e00

View File

@@ -3,14 +3,13 @@ from __future__ import annotations
import re import re
import sys import sys
from pathlib import Path from pathlib import Path
from typing import Any
if sys.version_info >= (3, 11): if sys.version_info >= (3, 11):
import tomllib import tomllib
else: else:
import tomli as tomllib import tomli as tomllib
from depaudit.parsers import Parser, ParsedManifest, Dependency from depaudit.parsers import Parser, ParsedManifest
class PythonParser(Parser): class PythonParser(Parser):
@@ -108,7 +107,7 @@ class PythonParser(Parser):
content = file_path.read_text(encoding="utf-8") content = file_path.read_text(encoding="utf-8")
install_requires_match = re.search( install_requires_match = re.search(
r"install_requires\s*=\s*\[([^\]]*)\]", content, re.DOTALL r"install_requires\s*=\s*\[(^\]]*)\]", content, re.DOTALL
) )
if install_requires_match: if install_requires_match:
deps_str = install_requires_match.group(1) deps_str = install_requires_match.group(1)
@@ -119,11 +118,11 @@ class PythonParser(Parser):
self._create_dependency(file_path, name, version) self._create_dependency(file_path, name, version)
) )
name_match = re.search(r'name\s*=\s*["']([^"\']+)["']', content) name_match = re.search(r'name\s*=\s*["']([^"']+)["']', content)
if name_match: if name_match:
manifest.project_name = name_match.group(1) manifest.project_name = name_match.group(1)
version_match = re.search(r'version\s*=\s*["']([^"\']+)["']', content) version_match = re.search(r'version\s*=\s*["']([^"']+)["']', content)
if version_match: if version_match:
manifest.project_version = version_match.group(1) manifest.project_version = version_match.group(1)
@@ -147,7 +146,7 @@ class PythonParser(Parser):
def _parse_pipfile(self, file_path: Path, manifest: ParsedManifest) -> None: def _parse_pipfile(self, file_path: Path, manifest: ParsedManifest) -> None:
content = file_path.read_text(encoding="utf-8") content = file_path.read_text(encoding="utf-8")
name_match = re.search(r'name\s*=\s*["']([^"\']+)["']', content) name_match = re.search(r'name\s*=\s*["']([^"']+)["']', content)
if name_match: if name_match:
manifest.project_name = name_match.group(1) manifest.project_name = name_match.group(1)
@@ -195,10 +194,8 @@ class PythonParser(Parser):
extras_match = re.match(r"([^\[]+)(?:\[([^\]]+)\])?", req) extras_match = re.match(r"([^\[]+)(?:\[([^\]]+)\])?", req)
if extras_match: if extras_match:
name = extras_match.group(1) name = extras_match.group(1)
extras = extras_match.group(2)
else: else:
name = req name = req
extras = None
for op in ["==", ">=", "<=", "~=", "!=", ">", "<", "==="]: for op in ["==", ">=", "<=", "~=", "!=", ">", "<", "==="]:
if op in name: if op in name: