Skip to content

Commit 0cc8c79

Browse files
author
DevForge Engineer
committed
chore: standardize license and package metadata; scanner/test fixes
1 parent 2db2c27 commit 0cc8c79

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/deadcode/scanner.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ def unreferenced_components(self) -> list[Finding]:
5858

5959
# ── Patterns ──────────────────────────────────────────────────────────
6060

61-
# export const/let/var/function/class/type/interface/enum
61+
# export const/let/var/function/class/type/interface/enum.
62+
# Deliberately does NOT match `export default ...`: with `default` in the
63+
# alternation the capture group grabbed the keyword `function`/`class` as
64+
# the export name, flagging every default export as removable dead code.
65+
# Default exports are entry-point conventions and are skipped entirely.
6266
_EXPORT_PATTERN = re.compile(
6367
r"^\s*export\s+"
64-
r"(?:const|let|var|function|class|type|interface|enum|default)\s+"
68+
r"(?:const|let|var|function|class|type|interface|enum)\s+"
6569
r"([A-Za-z_$][\w$]*)",
6670
re.MULTILINE,
6771
)

tests/test_config_and_fixes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,10 @@ def test_ruff_known_first_party(self):
517517
"""ruff known-first-party should be ['deadcode'], not ['*']."""
518518
from pathlib import Path
519519

520-
import tomllib
520+
try:
521+
import tomllib
522+
except ModuleNotFoundError: # Python 3.10 (requires-python >= 3.10)
523+
import tomli as tomllib
521524

522525
pyproject = Path(__file__).parent.parent / "pyproject.toml"
523526
with open(pyproject, "rb") as f:
@@ -530,7 +533,10 @@ def test_package_data_includes_py_typed(self):
530533
"""pyproject.toml should have package-data config for py.typed."""
531534
from pathlib import Path
532535

533-
import tomllib
536+
try:
537+
import tomllib
538+
except ModuleNotFoundError: # Python 3.10 (requires-python >= 3.10)
539+
import tomli as tomllib
534540

535541
pyproject = Path(__file__).parent.parent / "pyproject.toml"
536542
with open(pyproject, "rb") as f:

0 commit comments

Comments
 (0)