Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/exportify/export_manager/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from __future__ import annotations

import collections
from dataclasses import dataclass, field
from enum import IntEnum
from typing import TYPE_CHECKING, Literal
Expand Down Expand Up @@ -284,16 +285,21 @@ def _add_propagated_export(self, node: ModuleNode, entry: ExportEntry) -> None:
node.propagated_exports[name] = entry

def _validate_no_duplicates(self) -> None:
"""Validate no duplicate exports in same module."""
for module_path, node in self.modules.items():
# Check for duplicates in own_exports
export_names = list(node.own_exports.keys())
if len(export_names) != len(set(export_names)):
duplicates = [name for name in export_names if export_names.count(name) > 1]
raise ValueError(
f"❌ Error: Duplicate exports in module {module_path}\n\n"
f" Duplicates: {', '.join(set(duplicates))}"
)
"""Validate no duplicate exports in same module.

Notes
-----
`ModuleNode.own_exports` is a `dict` keyed by export name, so it
cannot contain duplicate keys by construction: inserting the same
name multiple times will simply overwrite the previous entry.

As a result, detecting duplicates by inspecting
`node.own_exports.keys()` can never succeed. If duplicate detection
is required, it must be implemented at insertion time (for example,
in the code that populates `own_exports`) *before* overwriting any
existing entry.
"""
return

def _validate_propagation_sources(self) -> None:
"""Validate all propagated exports have valid source modules."""
Expand Down
Loading