Specify the Python target version in ruff.toml
This ensures the same Python target version used for `ruff format` is used for `ruff check` as well. It also allows ruff, even if it's not run through pre-commit, to use the correct target Python version.
This commit is contained in:
parent
265ed76131
commit
c0232c6b5f
@ -30,8 +30,6 @@ repos:
|
||||
- id: ruff-format
|
||||
args:
|
||||
- --check
|
||||
- --target-version
|
||||
- py311
|
||||
exclude: ^source/tools/webservices/
|
||||
- repo: local
|
||||
hooks:
|
||||
|
@ -1,5 +1,7 @@
|
||||
line-length = 99
|
||||
|
||||
target-version = "py311"
|
||||
|
||||
[format]
|
||||
line-ending = "lf"
|
||||
|
||||
|
@ -8,7 +8,6 @@ from json import load, loads
|
||||
from logging import INFO, WARNING, Filter, Formatter, StreamHandler, getLogger
|
||||
from pathlib import Path
|
||||
from struct import calcsize, unpack
|
||||
from typing import Dict, List, Set, Tuple
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from scriptlib import SimulTemplateEntity, find_files
|
||||
@ -27,9 +26,9 @@ class SingleLevelFilter(Filter):
|
||||
|
||||
class CheckRefs:
|
||||
def __init__(self):
|
||||
self.files: List[Path] = []
|
||||
self.roots: List[Path] = []
|
||||
self.deps: List[Tuple[Path, Path]] = []
|
||||
self.files: list[Path] = []
|
||||
self.roots: list[Path] = []
|
||||
self.deps: list[tuple[Path, Path]] = []
|
||||
self.vfs_root = Path(__file__).resolve().parents[3] / "binaries" / "data" / "mods"
|
||||
self.supportedTextureFormats = ("dds", "png")
|
||||
self.supportedMeshesFormats = ("pmd", "dae")
|
||||
@ -794,7 +793,7 @@ class CheckRefs:
|
||||
uniq_files = {r.as_posix() for r in self.files}
|
||||
lower_case_files = {f.lower(): f for f in uniq_files}
|
||||
|
||||
missing_files: Dict[str, Set[str]] = defaultdict(set)
|
||||
missing_files: dict[str, set[str]] = defaultdict(set)
|
||||
|
||||
for parent, dep in self.deps:
|
||||
dep_str = dep.as_posix()
|
||||
|
@ -7,7 +7,6 @@ import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from subprocess import CalledProcessError, run
|
||||
from typing import Sequence
|
||||
from xml.etree import ElementTree as ET
|
||||
|
||||
from scriptlib import SimulTemplateEntity, find_files
|
||||
@ -50,7 +49,7 @@ errorch.setFormatter(logging.Formatter("%(levelname)s - %(message)s"))
|
||||
logger.addHandler(errorch)
|
||||
|
||||
|
||||
def main(argv: Sequence[str] | None = None) -> int:
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Validate templates")
|
||||
parser.add_argument("-m", "--mod-name", required=True, help="The name of the mod to validate.")
|
||||
parser.add_argument(
|
||||
@ -73,7 +72,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
)
|
||||
parser.add_argument("-v", "--verbose", help="Be verbose about the output.", default=False)
|
||||
|
||||
args = parser.parse_args(argv)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not args.relaxng_schema.exists():
|
||||
logging.error(RELAXNG_SCHEMA_ERROR_MSG.format(args.relaxng_schema))
|
||||
|
@ -22,7 +22,6 @@ import io
|
||||
import os
|
||||
import subprocess
|
||||
from itertools import islice
|
||||
from typing import List
|
||||
|
||||
from i18n_helper import PROJECT_ROOT_DIRECTORY
|
||||
|
||||
@ -38,7 +37,7 @@ def get_diff():
|
||||
return io.StringIO(diff_process.stdout.decode("utf-8"))
|
||||
|
||||
|
||||
def check_diff(diff: io.StringIO) -> List[str]:
|
||||
def check_diff(diff: io.StringIO) -> list[str]:
|
||||
"""Check a diff of .po files for meaningful changes.
|
||||
|
||||
Run through a diff of .po files and check that some of the changes
|
||||
@ -87,7 +86,7 @@ def check_diff(diff: io.StringIO) -> List[str]:
|
||||
return list(files.difference(keep))
|
||||
|
||||
|
||||
def revert_files(files: List[str], verbose=False):
|
||||
def revert_files(files: list[str], verbose=False):
|
||||
def batched(iterable, n):
|
||||
"""Split an iterable in equally sized chunks.
|
||||
|
||||
|
@ -1,12 +1,11 @@
|
||||
"""Utils to list .po."""
|
||||
|
||||
import os
|
||||
from typing import List, Optional
|
||||
|
||||
from i18n_helper.catalog import Catalog
|
||||
|
||||
|
||||
def get_catalogs(input_file_path, filters: Optional[List[str]] = None) -> List[Catalog]:
|
||||
def get_catalogs(input_file_path, filters: list[str] | None = None) -> list[Catalog]:
|
||||
"""Return a list of "real" catalogs (.po) in the given folder."""
|
||||
existing_translation_catalogs = []
|
||||
l10n_folder_path = os.path.dirname(input_file_path)
|
||||
|
@ -97,7 +97,7 @@ PATCHES_EXPECT_REVERT = [
|
||||
]
|
||||
|
||||
|
||||
@pytest.fixture(params=zip(PATCHES, PATCHES_EXPECT_REVERT))
|
||||
@pytest.fixture(params=zip(PATCHES, PATCHES_EXPECT_REVERT, strict=False))
|
||||
def patch(request):
|
||||
return [io.StringIO(request.param[0]), request.param[1]]
|
||||
|
||||
|
@ -7,11 +7,11 @@ import zero_ad
|
||||
|
||||
|
||||
def dist(p1, p2):
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2)))
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2, strict=False)))
|
||||
|
||||
|
||||
def center(units):
|
||||
sum_position = map(sum, zip(*(u.position() for u in units)))
|
||||
sum_position = map(sum, zip(*(u.position() for u in units), strict=False))
|
||||
return [x / len(units) for x in sum_position]
|
||||
|
||||
|
||||
|
@ -11,11 +11,11 @@ with open(path.join(scriptdir, "..", "samples", "arcadia.json"), encoding="utf-8
|
||||
|
||||
|
||||
def dist(p1, p2):
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2)))
|
||||
return math.sqrt(sum(math.pow(x2 - x1, 2) for (x1, x2) in zip(p1, p2, strict=False)))
|
||||
|
||||
|
||||
def center(units):
|
||||
sum_position = map(sum, zip(*(u.position() for u in units)))
|
||||
sum_position = map(sum, zip(*(u.position() for u in units), strict=False))
|
||||
return [x / len(units) for x in sum_position]
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ class RLAPI:
|
||||
def get_templates(self, names):
|
||||
post_data = "\n".join(names)
|
||||
response = self.post("templates", post_data)
|
||||
return zip(names, response.decode().split("\n"))
|
||||
return zip(names, response.decode().split("\n"), strict=False)
|
||||
|
||||
def evaluate(self, code):
|
||||
response = self.post("evaluate", code)
|
||||
|
@ -17,7 +17,7 @@ class ZeroAD:
|
||||
actions = []
|
||||
player_ids = cycle([self.player_id]) if player is None else cycle(player)
|
||||
|
||||
cmds = zip(player_ids, actions)
|
||||
cmds = zip(player_ids, actions, strict=False)
|
||||
cmds = ((player, action) for (player, action) in cmds if action is not None)
|
||||
state_json = self.api.step(cmds)
|
||||
self.current_state = GameState(json.loads(state_json), self)
|
||||
|
Loading…
Reference in New Issue
Block a user