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 remaining metadata to pyproject (home-assistant#72469)
- Loading branch information
Showing
10 changed files
with
62 additions
and
52 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
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
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 |
---|---|---|
@@ -1,31 +1,36 @@ | ||
"""Package metadata validation.""" | ||
import configparser | ||
import sys | ||
|
||
from homeassistant.const import REQUIRED_PYTHON_VER, __version__ | ||
|
||
from .model import Config, Integration | ||
|
||
if sys.version_info >= (3, 11): | ||
import tomllib | ||
else: | ||
import tomli as tomllib | ||
|
||
|
||
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) | ||
metadata_path = config.root / "pyproject.toml" | ||
with open(metadata_path, "rb") as fp: | ||
data = tomllib.load(fp) | ||
|
||
try: | ||
if parser["metadata"]["version"] != __version__: | ||
if data["project"]["version"] != __version__: | ||
config.add_error( | ||
"metadata", f"'metadata.version' value does not match '{__version__}'" | ||
"metadata", f"'project.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: | ||
if data["project"]["requires-python"] != required_py_version: | ||
config.add_error( | ||
"metadata", | ||
f"'options.python_requires' value doesn't match '{required_py_version}", | ||
f"'project.requires-python' 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