mirror of
https://github.com/tldr-pages/tldr.git
synced 2026-08-28 19:54:09 +08:00
scripts/_common: fix type checker issues (#20460)
This commit is contained in:
+5
-4
@@ -7,6 +7,7 @@ A Python file that makes some commonly used functions available for other script
|
|||||||
|
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Optional
|
||||||
from unittest.mock import patch
|
from unittest.mock import patch
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
import os
|
||||||
@@ -35,7 +36,7 @@ def test_ignore_files():
|
|||||||
assert "tldr.md" not in IGNORE_FILES
|
assert "tldr.md" not in IGNORE_FILES
|
||||||
|
|
||||||
|
|
||||||
def get_tldr_root(lookup_path: Path = None) -> Path:
|
def get_tldr_root(lookup_path: Optional[str] = None) -> Path:
|
||||||
"""
|
"""
|
||||||
Get the path of the local tldr repository, looking for it in each part of the given path. If it is not found, the path in the environment variable TLDR_ROOT is returned.
|
Get the path of the local tldr repository, looking for it in each part of the given path. If it is not found, the path in the environment variable TLDR_ROOT is returned.
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ def test_get_pages_dirs():
|
|||||||
|
|
||||||
|
|
||||||
def get_target_paths(
|
def get_target_paths(
|
||||||
page: Path, pages_dirs: Path, check_exists: bool = True
|
page: str, pages_dirs: list[Path], check_exists: bool = True
|
||||||
) -> list[Path]:
|
) -> list[Path]:
|
||||||
"""
|
"""
|
||||||
Get all paths in all languages that match the page.
|
Get all paths in all languages that match the page.
|
||||||
@@ -219,8 +220,8 @@ def test_get_target_paths():
|
|||||||
|
|
||||||
root.mkdir(exist_ok=True)
|
root.mkdir(exist_ok=True)
|
||||||
|
|
||||||
shutil.os.makedirs(root / "pages" / "common")
|
(root / "pages" / "common").mkdir(parents=True, exist_ok=True)
|
||||||
shutil.os.makedirs(root / "pages.fr" / "common")
|
(root / "pages.fr" / "common").mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
file_path = root / "pages" / "common" / "tldr.md"
|
file_path = root / "pages" / "common" / "tldr.md"
|
||||||
with open(file_path, "w"):
|
with open(file_path, "w"):
|
||||||
|
|||||||
Reference in New Issue
Block a user