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

Update dependency ruff to ^0.9.2 #2671

Merged
merged 3 commits into from
Jan 20, 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
40 changes: 20 additions & 20 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ sphinxcontrib-programoutput = "^0.17"

[tool.poetry.group.lint.dependencies]
black = "^24.10.0"
ruff = "^0.7.4"
ruff = "^0.9.2"

[tool.poetry.group.test.dependencies]
coverage = {extras = ["toml"], version = "^7.6.10"}
Expand Down Expand Up @@ -248,8 +248,6 @@ extend-safe-fixes = [
"UP040",
]
ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed # TODO (kyle): improve type annotations
"COM812", # Trailing comma missing
"D203", # 1 blank line required before class docstring
Expand Down Expand Up @@ -293,7 +291,6 @@ select = ["ALL"]
"N999", # Invalid module name # NOTE (kyle): these are fine here
]
"tests/*" = [
"PT004", # Fixture does not return anything, add leading underscore
"S101", # Use of `assert` detected # NOTE (kyle): this is fine here
"SLF001", # Private member accessed # NOTE (kyle): fine in tests
]
Expand Down
2 changes: 1 addition & 1 deletion runway/_cli/commands/_gen_sample/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
"cfn",
"cfngin",
"k8s_cfn_repo",
"k8s_tf_repo",
"k8s_flux_repo",
"k8s_tf_repo",
"sls_py",
"sls_tsc",
"static_angular",
Expand Down
2 changes: 1 addition & 1 deletion runway/cfngin/blueprints/variables/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""CFNgin blueprint variable types."""
"""CFNgin blueprint variable types.""" # noqa: A005

from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion runway/cfngin/hooks/awslambda/deployment_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class DeploymentPackage(DelCachedPropMixin, Generic[_ProjectTypeVar]):
}
"""Mapping of metadata to the tag-key is is stored in on the S3 object."""

SIZE_EOCD: Final[Literal[22]] = 22
SIZE_EOCD: Final = 22
"""Size of a zip file's End of Central Directory Record (empty zip)."""

ZIPFILE_PERMISSION_MASK: ClassVar[int] = (stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO) << 16
Expand Down
14 changes: 7 additions & 7 deletions runway/cfngin/hooks/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ class CfnginHookArgsProtocol(Protocol):

@overload
@abstractmethod
def get(self, __name: str) -> Any | None: ...
def get(self, _name: str) -> Any | None: ...

@overload
@abstractmethod
def get(self, __name: str, __default: Any | _T) -> Any | _T: ...
def get(self, _name: str, _default: Any | _T) -> Any | _T: ...

@abstractmethod
def get(self, __name: str, __default: Any | _T = None) -> Any | _T:
def get(self, _name: str, _default: Any | _T = None) -> Any | _T:
"""Safely get the value of an attribute.

Args:
Expand All @@ -48,19 +48,19 @@ def get(self, __name: str, __default: Any | _T = None) -> Any | _T:
raise NotImplementedError

@abstractmethod
def __contains__(self, __name: str) -> bool: # noqa: D105
def __contains__(self, _name: str) -> bool: # noqa: D105
raise NotImplementedError

@abstractmethod
def __getattribute__(self, __name: str) -> Any: # noqa: D105
def __getattribute__(self, _name: str) -> Any: # noqa: D105
raise NotImplementedError

@abstractmethod
def __getitem__(self, __name: str) -> Any: # noqa: D105
def __getitem__(self, _name: str) -> Any: # noqa: D105
raise NotImplementedError

@abstractmethod
def __setitem__(self, __name: str, _value: Any) -> None: # noqa: D105
def __setitem__(self, _name: str, _value: Any) -> None: # noqa: D105
raise NotImplementedError


Expand Down
2 changes: 1 addition & 1 deletion runway/cfngin/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def sanitize_git_path(self, uri: str, ref: str | None = None) -> str:
Directory name for the supplied uri

"""
dir_name = uri[:-4] if uri.endswith(".git") else uri # drop .git
dir_name = uri.removesuffix(".git") # drop .git
dir_name = self.sanitize_uri_path(dir_name)
if ref is not None:
dir_name += f"-{ref}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"ExactTimestampsSync",
"MissingFileSync",
"NeverSync",
"register_sync_strategies",
"SizeAndLastModifiedSync",
"SizeOnlySync",
"register_sync_strategies",
]
3 changes: 1 addition & 2 deletions runway/core/providers/aws/s3/_helpers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,7 @@ def split_s3_bucket_key(s3_path: str) -> tuple[str, str]:
Bucket name, key

"""
if s3_path.startswith("s3://"):
s3_path = s3_path[5:]
s3_path = s3_path.removeprefix("s3://")
return find_bucket_key(s3_path)


Expand Down
2 changes: 1 addition & 1 deletion runway/lookups/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LookupHandler(ABC, Generic[ContextTypeVar]):
"""Name that the Lookup is registered as."""

@classmethod
def dependencies(cls, __lookup_query: VariableValue) -> set[str]:
def dependencies(cls, _lookup_query: VariableValue) -> set[str]:
"""Calculate any dependencies required to perform this lookup.

Note that lookup_query may not be (completely) resolved at this time.
Expand Down
66 changes: 32 additions & 34 deletions runway/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,13 +397,13 @@ def resolve(
for item in self.values():
item.resolve(context, provider=provider, variables=variables, **kwargs)

def __delitem__(self, __key: str) -> None:
def __delitem__(self, _key: str) -> None:
"""Delete item by index."""
del self._data[__key]
del self._data[_key]

def __getitem__(self, __key: str) -> VariableValue:
def __getitem__(self, _key: str) -> VariableValue:
"""Get item by index."""
return self._data[__key]
return self._data[_key]

def __iter__(self) -> Iterator[str]:
"""How the object is iterated."""
Expand All @@ -417,9 +417,9 @@ def __repr__(self) -> str:
"""Return object representation."""
return f"dict[{', '.join(f'{k}={v}' for k, v in self.items())}]"

def __setitem__(self, __key: str, __value: VariableValue) -> None:
def __setitem__(self, _key: str, _value: VariableValue) -> None:
"""Set item by index."""
self._data[__key] = __value
self._data[_key] = _value


class VariableValueList(VariableValue, MutableSequence[VariableValue]):
Expand Down Expand Up @@ -507,30 +507,28 @@ def __delitem__(self, index: int | slice) -> None:
del self._data[index]

@overload
def __getitem__(self, __index: int) -> VariableValue: ...
def __getitem__(self, _index: int) -> VariableValue: ...

@overload
def __getitem__(self, __index: slice) -> list[VariableValue]: ...
def __getitem__(self, _index: slice) -> list[VariableValue]: ...

def __getitem__( # pyright: ignore[reportIncompatibleMethodOverride]
self, __index: int | slice
) -> MutableSequence[VariableValue] | VariableValue:
def __getitem__(self, _index: int | slice) -> MutableSequence[VariableValue] | VariableValue:
"""Get item by index."""
return self._data[__index]
return self._data[_index]

@overload
def __setitem__(self, __index: int, __value: VariableValue) -> None: ...
def __setitem__(self, _index: int, _value: VariableValue) -> None: ...

@overload
def __setitem__(self, __index: slice, __value: list[VariableValue]) -> None: ...
def __setitem__(self, _index: slice, _value: list[VariableValue]) -> None: ...

def __setitem__( # pyright: ignore[reportIncompatibleMethodOverride]
self,
__index: int | slice,
__value: list[VariableValue] | VariableValue,
_index: int | slice,
_value: list[VariableValue] | VariableValue,
) -> None:
"""Set item by index."""
self._data[__index] = __value # type: ignore
self._data[_index] = _value # type: ignore

def __iter__(self) -> Iterator[VariableValue]:
"""Object iteration."""
Expand Down Expand Up @@ -688,33 +686,33 @@ def resolve(
for value in self:
value.resolve(context, provider=provider, variables=variables, **kwargs)

def __delitem__(self, __index: int) -> None:
def __delitem__(self, _index: int) -> None:
"""Delete item by index."""
del self._data[__index]
del self._data[_index]

@overload
def __getitem__(self, __index: int) -> _VariableValue: ...
def __getitem__(self, _index: int) -> _VariableValue: ...

@overload
def __getitem__(self, __index: slice) -> list[_VariableValue]: ...
def __getitem__(self, _index: slice) -> list[_VariableValue]: ...

def __getitem__(self, __index: int | slice) -> list[_VariableValue] | _VariableValue:
def __getitem__(self, _index: int | slice) -> list[_VariableValue] | _VariableValue:
"""Get item by index."""
return self._data[__index]
return self._data[_index]

@overload
def __setitem__(self, __index: int, __value: _VariableValue) -> None: ...
def __setitem__(self, _index: int, _value: _VariableValue) -> None: ...

@overload
def __setitem__(self, __index: slice, __value: list[_VariableValue]) -> None: ...
def __setitem__(self, _index: slice, _value: list[_VariableValue]) -> None: ...

def __setitem__(
self,
__index: int | slice,
__value: list[_VariableValue] | _VariableValue,
_index: int | slice,
_value: list[_VariableValue] | _VariableValue,
) -> None:
"""Set item by index."""
self._data[__index] = __value
self._data[_index] = _value

def __iter__(self) -> Iterator[_VariableValue]:
"""Object iteration."""
Expand Down Expand Up @@ -940,13 +938,13 @@ def resolve(
for item in self._data.values():
item.resolve(context, provider=provider, variables=variables, **kwargs)

def __delitem__(self, __key: str) -> None:
def __delitem__(self, _key: str) -> None:
"""Delete item by index."""
del self._data[__key]
del self._data[_key]

def __getitem__(self, __key: str) -> VariableValue:
def __getitem__(self, _key: str) -> VariableValue:
"""Get item by index."""
return self._data[__key]
return self._data[_key]

def __iter__(self) -> Iterator[str]:
"""How the object is iterated."""
Expand All @@ -962,6 +960,6 @@ def __repr__(self) -> str:
self._model_class.__name__ + f"[{', '.join(f'{k}={v}' for k, v in self._data.items())}]"
)

def __setitem__(self, __key: str, __value: VariableValue) -> None:
def __setitem__(self, _key: str, _value: VariableValue) -> None:
"""Set item by index."""
self._data[__key] = __value
self._data[_key] = _value
2 changes: 1 addition & 1 deletion tests/unit/cfngin/fixtures/mock_lookups.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
TYPE_NAME = "mock"


def handler(__value: Any, *, _: Any) -> str:
def handler(_value: Any, *, _: Any) -> str:
"""Mock handler."""
return "mock"
2 changes: 1 addition & 1 deletion tests/unit/utils/pydantic_validators/test__lax_str.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Model(BaseModel):
("foo", "foo"),
(5, "5"),
(1.0, "1.0"),
(Decimal(1.0), "1"),
(Decimal("1.0"), "1.0"),
(SomeEnum.FOO, "foo"),
(b"foo", "foo"),
(None, None),
Expand Down
Loading