Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Activate ANN002, ANN206, PTH102, PTH119 #3788

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 1 addition & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,10 @@ ignore = [
### TODO : remove those ignores
# missing-type-annotation, the ONE to remove !!
"ANN001",
"ANN002",
"ANN003",
"ANN201",
"ANN202",
"ANN205",
"ANN206",
"BLE001", # Do not catch blind exception: `Exception`, big project to enable this
"C901", # code complexity, TBD
"E722", # bare except, big project to enable this
Expand All @@ -97,14 +95,12 @@ ignore = [
"PLR1714",
"PLR2004",
"PTH100",
"PTH102",
"PTH110",
"PTH113",
"PTH116",
"PTH118",
"PTH119",
"PTH120",
"PTH122",
"PTH122", # os.path.splitext(), but not really easier to read ?
"PTH123", # `open()` should be replaced by `Path.open()`
"RUF012",
"S202",
Expand Down Expand Up @@ -248,7 +244,6 @@ ignore = [
"EM102",
"PLR0912",
"PLR0915",
"PLR1714",
"PLW1510",
"PTH112",
"PTH113",
Expand Down
3 changes: 2 additions & 1 deletion utils/_context/virtual_machines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import hashlib
from pathlib import Path

from utils.tools import logger
from utils import context
Expand Down Expand Up @@ -178,7 +179,7 @@ def _load_ip_from_logs(self):
def get_log_folder(self):
vm_folder = f"{context.scenario.host_log_folder}/{self.name}"
if not os.path.exists(vm_folder):
os.mkdir(vm_folder)
Path.mkdir(vm_folder)
return vm_folder

def get_default_log_file(self):
Expand Down
2 changes: 1 addition & 1 deletion utils/_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class _DecoratorType(enum.StrEnum):
# So we use a custom one, based on NPM spec, allowing pre-release versions
class CustomParser(semver.NpmSpec.Parser):
@classmethod
def range(cls, operator, target):
def range(cls, operator, target) -> semver.base.Range:
return semver.base.Range(operator, target, prerelease_policy=semver.base.Range.PRERELEASE_ALWAYS)


Expand Down
3 changes: 1 addition & 2 deletions utils/cgroup_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ class _CGroupInfo:
CONTAINER_RE = re.compile(rf"(?:.+)?({UUID_SOURCE_PATTERN}|{CONTAINER_SOURCE_PATTERN}|{TASK_PATTERN})(?:\.scope)?$")

@classmethod
def from_line(cls, line):
# type: (str) -> Optional[_CGroupInfo]
def from_line(cls, line: str) -> "_CGroupInfo | None":
"""Parse a new :class:`CGroupInfo` from the provided line
:param line: A line from a cgroup file (e.g. /proc/self/cgroup) to parse information from
:type line: str
Expand Down
4 changes: 2 additions & 2 deletions utils/onboarding/injection_log_parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
import os
from pathlib import Path

from utils.tools import logger

Expand Down Expand Up @@ -58,7 +58,7 @@ def _parse_command(command):
if "=" in com:
command_args.remove(com)
continue
return os.path.basename(com), command_args
return Path(com).name, command_args

return None, None

Expand Down
2 changes: 1 addition & 1 deletion utils/parametric/spec/tracecontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Tracestate:
_VALUE_VALIDATION_RE = re.compile("^(" + _VALUE_FORMAT + ")$")
_MEMBER_FORMAT_RE = re.compile(f"^({_KEY_FORMAT})(=)({_VALUE_FORMAT})$")

def __init__(self, *args, **kwds):
def __init__(self, *args, **kwds): # noqa: ANN002
if len(args) == 1 and not kwds:
if isinstance(args[0], str):
self._traits: OrderedDict = OrderedDict()
Expand Down
2 changes: 1 addition & 1 deletion utils/proxy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


class CustomFormatter(logging.Formatter):
def __init__(self, keys: list[str], *args, **kwargs) -> None:
def __init__(self, keys: list[str], *args, **kwargs) -> None: # noqa: ANN002
super().__init__(*args, **kwargs)
self._keys = keys

Expand Down
2 changes: 1 addition & 1 deletion utils/scripts/markdown_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import collections


def table_row(*args):
def table_row(*args: list[str]):
print(f"| {' | '.join(args)} |")


Expand Down
2 changes: 1 addition & 1 deletion utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def update_environ_with_local_env():
logging.addLevelName(DEBUG_LEVEL_STDOUT, "STDOUT")


def stdout(self, message, *args, **kws):
def stdout(self, message, *args, **kws): # noqa: ANN002
if self.isEnabledFor(DEBUG_LEVEL_STDOUT):
# Yes, logger takes its '*args' as 'args'.
self._log(DEBUG_LEVEL_STDOUT, message, args, **kws) # pylint: disable=protected-access
Expand Down
Loading