mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-07 05:54:02 +08:00
Enable Ruff PLW (Pylint Warning) (#13749)
This commit is contained in:
@@ -59,17 +59,17 @@ def run_stubgen(package: str, output: str) -> None:
|
||||
|
||||
def run_stubdefaulter(stub_dir: str) -> None:
|
||||
print(f"Running stubdefaulter: stubdefaulter --packages {stub_dir}")
|
||||
subprocess.run(["stubdefaulter", "--packages", stub_dir])
|
||||
subprocess.run(["stubdefaulter", "--packages", stub_dir], check=False)
|
||||
|
||||
|
||||
def run_black(stub_dir: str) -> None:
|
||||
print(f"Running Black: black {stub_dir}")
|
||||
subprocess.run(["pre-commit", "run", "black", "--files", *glob.iglob(f"{stub_dir}/**/*.pyi")])
|
||||
subprocess.run(["pre-commit", "run", "black", "--files", *glob.iglob(f"{stub_dir}/**/*.pyi")], check=False)
|
||||
|
||||
|
||||
def run_ruff(stub_dir: str) -> None:
|
||||
print(f"Running Ruff: ruff check {stub_dir} --fix-only")
|
||||
subprocess.run([sys.executable, "-m", "ruff", "check", stub_dir, "--fix-only"])
|
||||
subprocess.run([sys.executable, "-m", "ruff", "check", stub_dir, "--fix-only"], check=False)
|
||||
|
||||
|
||||
async def get_project_urls_from_pypi(project: str, session: aiohttp.ClientSession) -> dict[str, str]:
|
||||
@@ -102,9 +102,9 @@ async def get_upstream_repo_url(project: str) -> str | None:
|
||||
url for url_name, url in project_urls.items() if url_name not in url_names_probably_pointing_to_source
|
||||
)
|
||||
|
||||
for url in urls_to_check:
|
||||
for url_to_check in urls_to_check:
|
||||
# Remove `www.`; replace `http://` with `https://`
|
||||
url = re.sub(r"^(https?://)?(www\.)?", "https://", url)
|
||||
url = re.sub(r"^(https?://)?(www\.)?", "https://", url_to_check)
|
||||
netloc = urllib.parse.urlparse(url).netloc
|
||||
if netloc in {"gitlab.com", "github.com", "bitbucket.org", "foss.heptapod.net"}:
|
||||
# truncate to https://site.com/user/repo
|
||||
|
||||
@@ -754,8 +754,8 @@ async def main() -> None:
|
||||
dists_to_update = [path.name for path in STUBS_PATH.iterdir()]
|
||||
|
||||
if args.action_level > ActionLevel.nothing:
|
||||
subprocess.run(["git", "update-index", "--refresh"], capture_output=True)
|
||||
diff_result = subprocess.run(["git", "diff-index", "HEAD", "--name-only"], text=True, capture_output=True)
|
||||
subprocess.run(["git", "update-index", "--refresh"], capture_output=True, check=False)
|
||||
diff_result = subprocess.run(["git", "diff-index", "HEAD", "--name-only"], text=True, capture_output=True, check=False)
|
||||
if diff_result.returncode:
|
||||
print("Unexpected exception!")
|
||||
print(diff_result.stdout)
|
||||
|
||||
@@ -35,7 +35,9 @@ def run_protoc(
|
||||
) -> str:
|
||||
"""TODO: Describe parameters and return."""
|
||||
protoc_version = (
|
||||
subprocess.run([sys.executable, "-m", "grpc_tools.protoc", "--version"], capture_output=True).stdout.decode().strip()
|
||||
subprocess.run([sys.executable, "-m", "grpc_tools.protoc", "--version"], capture_output=True, check=False)
|
||||
.stdout.decode()
|
||||
.strip()
|
||||
)
|
||||
print()
|
||||
print(protoc_version)
|
||||
|
||||
@@ -90,7 +90,7 @@ and {protoc_version} on \
|
||||
print("Updated protobuf/METADATA.toml")
|
||||
|
||||
# Run pre-commit to cleanup the stubs
|
||||
subprocess.run((sys.executable, "-m", "pre_commit", "run", "--files", *STUBS_FOLDER.rglob("*_pb2.pyi")))
|
||||
subprocess.run((sys.executable, "-m", "pre_commit", "run", "--files", *STUBS_FOLDER.rglob("*_pb2.pyi")), check=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -69,7 +69,7 @@ and {protoc_version} on \
|
||||
print("Updated s2clientprotocol/METADATA.toml")
|
||||
|
||||
# Run pre-commit to cleanup the stubs
|
||||
subprocess.run((sys.executable, "-m", "pre_commit", "run", "--files", *STUBS_FOLDER.rglob("*_pb2.pyi")))
|
||||
subprocess.run((sys.executable, "-m", "pre_commit", "run", "--files", *STUBS_FOLDER.rglob("*_pb2.pyi")), check=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -72,7 +72,7 @@ def post_creation() -> None:
|
||||
|
||||
for path in STUBS_FOLDER.rglob("*_pb2.pyi"):
|
||||
print(f"Fixing imports in '{path}'")
|
||||
with open(path) as file:
|
||||
with open(path, encoding="utf-8") as file:
|
||||
filedata = file.read()
|
||||
|
||||
# Replace the target string
|
||||
@@ -80,7 +80,7 @@ def post_creation() -> None:
|
||||
filedata = re.sub(XLA_IMPORT_PATTERN, "\\1tensorflow.compiler.xla.", filedata)
|
||||
|
||||
# Write the file out again
|
||||
with open(path, "w") as file:
|
||||
with open(path, "w", encoding="utf-8") as file:
|
||||
file.write(filedata)
|
||||
|
||||
print()
|
||||
@@ -137,7 +137,7 @@ and {protoc_version} on `tensorflow=={PACKAGE_VERSION}`.""",
|
||||
print("Updated tensorflow/METADATA.toml")
|
||||
|
||||
# Run pre-commit to cleanup the stubs
|
||||
subprocess.run((sys.executable, "-m", "pre_commit", "run", "--files", *STUBS_FOLDER.rglob("*_pb2.pyi")))
|
||||
subprocess.run((sys.executable, "-m", "pre_commit", "run", "--files", *STUBS_FOLDER.rglob("*_pb2.pyi")), check=False)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user