mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Enable Ruff D (pydocstyle) with pep257 convention (#13326)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -33,7 +33,7 @@ def extract_archive(archive_path: StrPath, destination: StrPath) -> None:
|
||||
def run_protoc(
|
||||
proto_paths: Iterable[StrPath], mypy_out: StrPath, proto_globs: Iterable[str], cwd: StrOrBytesPath | None = None
|
||||
) -> str:
|
||||
"""TODO: Describe parameters and return"""
|
||||
"""TODO: Describe parameters and return."""
|
||||
protoc_version = (
|
||||
subprocess.run([sys.executable, "-m", "grpc_tools.protoc", "--version"], capture_output=True).stdout.decode().strip()
|
||||
)
|
||||
|
||||
@@ -32,7 +32,7 @@ PROTO_FILE_PATTERN = re.compile(r'"//:(.*)_proto"')
|
||||
|
||||
|
||||
def extract_python_version(file_path: Path) -> str:
|
||||
"""Extract the Python version from https://github.com/protocolbuffers/protobuf/blob/main/version.json"""
|
||||
"""Extract the Python version from https://github.com/protocolbuffers/protobuf/blob/main/version.json ."""
|
||||
with open(file_path) as file:
|
||||
data: dict[str, Any] = json.load(file)
|
||||
# The root key will be the protobuf source code version
|
||||
@@ -45,7 +45,7 @@ def extract_proto_file_paths(temp_dir: Path) -> list[str]:
|
||||
"""
|
||||
Roughly reproduce the subset of .proto files on the public interface
|
||||
as described in py_proto_library calls in
|
||||
https://github.com/protocolbuffers/protobuf/blob/main/python/dist/BUILD.bazel
|
||||
https://github.com/protocolbuffers/protobuf/blob/main/python/dist/BUILD.bazel .
|
||||
"""
|
||||
with open(temp_dir / EXTRACTED_PACKAGE_DIR / "python" / "dist" / "BUILD.bazel") as file:
|
||||
matched_lines = filter(None, (re.search(PROTO_FILE_PATTERN, line) for line in file))
|
||||
|
||||
@@ -30,7 +30,7 @@ VERSION_PATTERN = re.compile(r'def game_version\(\):\n return "(.+?)"')
|
||||
|
||||
|
||||
def extract_python_version(file_path: Path) -> str:
|
||||
"""Extract Python version from s2clientprotocol's build file"""
|
||||
"""Extract Python version from s2clientprotocol's build file."""
|
||||
match = re.search(VERSION_PATTERN, file_path.read_text())
|
||||
assert match
|
||||
return match.group(1)
|
||||
|
||||
@@ -57,14 +57,15 @@ XLA_IMPORT_PATTERN = re.compile(r"(\[|\s)xla\.")
|
||||
def move_tree(source: Path, destination: Path) -> None:
|
||||
"""Move directory and merge if destination already exists.
|
||||
|
||||
Can't use shutil.move because it can't merge existing directories."""
|
||||
Can't use shutil.move because it can't merge existing directories.
|
||||
"""
|
||||
print(f"Moving '{source}' to '{destination}'")
|
||||
shutil.copytree(source, destination, dirs_exist_ok=True)
|
||||
shutil.rmtree(source)
|
||||
|
||||
|
||||
def post_creation() -> None:
|
||||
"""Move third-party and fix imports"""
|
||||
"""Move third-party and fix imports."""
|
||||
print()
|
||||
move_tree(STUBS_FOLDER / "tsl", STUBS_FOLDER / "tensorflow" / "tsl")
|
||||
move_tree(STUBS_FOLDER / "xla", STUBS_FOLDER / "tensorflow" / "compiler" / "xla")
|
||||
|
||||
Reference in New Issue
Block a user