Skip to content

Commit

Permalink
allow dynamic version
Browse files Browse the repository at this point in the history
Name is the only field than cannot be dynamic: https://peps.python.org/pep-0621/#name
  • Loading branch information
kingarrrt committed Oct 19, 2023
1 parent fd1da74 commit 219b22f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pyproject_metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ def write_to_rfc822(self, message: RFC822Message) -> None: # noqa: C901
message['Description-Content-Type'] = self.readme.content_type
message.body = self.readme.text
# Core Metadata 2.2
if 'name' in self.dynamic:
raise ConfigurationError('Name cannot be dynamic')
for field in self.dynamic:
if field in ('name', 'version'):
raise ConfigurationError(f'Field cannot be dynamic: {field}')
message['Dynamic'] = field

def _name_list(self, people: list[tuple[str, str]]) -> str:
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 @@ -642,10 +642,7 @@ def test_as_rfc822_invalid_dynamic():
version=packaging.version.Version('1.0.0'),
)
metadata.dynamic = ['name']
with pytest.raises(pyproject_metadata.ConfigurationError, match='Field cannot be dynamic: name'):
metadata.as_rfc822()
metadata.dynamic = ['version']
with pytest.raises(pyproject_metadata.ConfigurationError, match='Field cannot be dynamic: version'):
with pytest.raises(pyproject_metadata.ConfigurationError, match='Name cannot be dynamic'):
metadata.as_rfc822()


Expand Down

0 comments on commit 219b22f

Please sign in to comment.