Skip to content

Commit

Permalink
revert: remove attribute locking
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Oct 16, 2024
1 parent 49fd43f commit 4fbac97
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
14 changes: 0 additions & 14 deletions pyproject_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,23 +252,10 @@ class StandardMetadata:
"""
If True, all errors will be collected and raised in an ExceptionGroup.
"""
_locked_metadata: bool = False
"""
Internal flag to prevent setting non-dynamic fields after initialization.
"""

def __post_init__(self) -> None:
self.validate()

def __setattr__(self, name: str, value: Any) -> None:
if self._locked_metadata:
metadata_name = name.replace("_", "-")
locked_fields = constants.KNOWN_METADATA_FIELDS - set(self.dynamic)
if metadata_name in locked_fields:
msg = f"Field {name!r} is not dynamic"
raise AttributeError(msg)
super().__setattr__(name, value)

@property
def auto_metadata_version(self) -> str:
"""
Expand Down Expand Up @@ -442,7 +429,6 @@ def from_pyproject( # noqa: C901
metadata_version=metadata_version,
all_errors=all_errors,
)
self._locked_metadata = True

pyproject.finalize("Failed to parse pyproject.toml")
assert self is not None
Expand Down
5 changes: 1 addition & 4 deletions tests/test_standard_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1455,10 +1455,7 @@ def test_modify_dynamic() -> None:
}
)
metadata.requires_python = packaging.specifiers.SpecifierSet(">=3.12")
with pytest.raises(
AttributeError, match=re.escape("Field 'version' is not dynamic")
):
metadata.version = packaging.version.Version("1.2.3")
metadata.version = packaging.version.Version("1.2.3")


def test_missing_keys_warns() -> None:
Expand Down

0 comments on commit 4fbac97

Please sign in to comment.