Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.14] gh-133403: CheckTools/build/generate-build-details.py with mypy (GH-133735)#133764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes fromall 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
1 change: 1 addition & 0 deletions.github/workflows/mypy.yml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -15,6 +15,7 @@ on:
- "Misc/mypy/**"
- "Tools/build/compute-changes.py"
- "Tools/build/generate_sbom.py"
- "Tools/build/generate-build-details.py"
- "Tools/build/verify_ensurepip_wheels.py"
- "Tools/build/update_file.py"
- "Tools/cases_generator/**"
Expand Down
20 changes: 14 additions & 6 deletionsTools/build/generate-build-details.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,8 @@
# Script initially imported from:
# https://github.com/FFY00/python-instrospection/blob/main/python_introspection/scripts/generate-build-details.py

from __future__ import annotations

import argparse
import collections
import importlib.machinery
Expand All@@ -11,19 +13,23 @@
import sys
import sysconfig

TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any


def version_info_to_dict(obj): # (object) -> dict[str, Any]
def version_info_to_dict(obj: sys._version_info) -> dict[str, Any]:
field_names = ('major', 'minor', 'micro', 'releaselevel', 'serial')
return {field: getattr(obj, field) for field in field_names}


def get_dict_key(container, key): # (dict[str, Any], str) -> dict[str, Any]
def get_dict_key(container:dict[str, Any],key:str) -> dict[str, Any]:
for part in key.split('.'):
container = container[part]
return container


def generate_data(schema_version):
def generate_data(schema_version: str) -> collections.defaultdict[str, Any]:
"""Generate the build-details.json data (PEP 739).

:param schema_version: The schema version of the data we want to generate.
Expand All@@ -32,7 +38,9 @@ def generate_data(schema_version):
if schema_version != '1.0':
raise ValueError(f'Unsupported schema_version: {schema_version}')

data = collections.defaultdict(lambda: collections.defaultdict(dict))
data: collections.defaultdict[str, Any] = collections.defaultdict(
lambda: collections.defaultdict(dict),
)

data['schema_version'] = schema_version

Expand DownExpand Up@@ -122,7 +130,7 @@ def generate_data(schema_version):
return data


def make_paths_relative(data, config_path=None): # (dict[str, Any], str | None) -> None
def make_paths_relative(data:dict[str, Any],config_path:str | None = None) -> None:
# Make base_prefix relative to the config_path directory
if config_path:
data['base_prefix'] = os.path.relpath(data['base_prefix'], os.path.dirname(config_path))
Expand DownExpand Up@@ -152,7 +160,7 @@ def make_paths_relative(data, config_path=None): # (dict[str, Any], str | None)
container[child] = new_path


def main(): # ()-> None
def main()-> None:
parser = argparse.ArgumentParser(exit_on_error=False)
parser.add_argument('location')
parser.add_argument(
Expand Down
1 change: 1 addition & 0 deletionsTools/build/mypy.ini
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@
# .github/workflows/mypy.yml
files =
Tools/build/compute-changes.py,
Tools/build/generate-build-details.py,
Tools/build/generate_sbom.py,
Tools/build/verify_ensurepip_wheels.py,
Tools/build/update_file.py
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp