forked from home-assistant/core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move version metadata key to setup.cfg (home-assistant#65091)
* Move version to setup.cfg * Move python_requires to setup.cfg * Add script to validate project metadata * Add dedicated pre-commit hook
- Loading branch information
Showing
6 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Package metadata validation.""" | ||
import configparser | ||
|
||
from homeassistant.const import REQUIRED_PYTHON_VER, __version__ | ||
|
||
from .model import Config, Integration | ||
|
||
|
||
def validate(integrations: dict[str, Integration], config: Config) -> None: | ||
"""Validate project metadata keys.""" | ||
metadata_path = config.root / "setup.cfg" | ||
parser = configparser.ConfigParser() | ||
parser.read(metadata_path) | ||
|
||
try: | ||
if parser["metadata"]["version"] != __version__: | ||
config.add_error( | ||
"metadata", f"'metadata.version' value does not match '{__version__}'" | ||
) | ||
except KeyError: | ||
config.add_error("metadata", "No 'metadata.version' key found!") | ||
|
||
required_py_version = f">={'.'.join(map(str, REQUIRED_PYTHON_VER))}" | ||
try: | ||
if parser["options"]["python_requires"] != required_py_version: | ||
config.add_error( | ||
"metadata", | ||
f"'options.python_requires' value doesn't match '{required_py_version}", | ||
) | ||
except KeyError: | ||
config.add_error("metadata", "No 'options.python_requires' key found!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters