Skip to content

Commit

Permalink
Update dependency ruff to v0.2.2 (#469)
Browse files Browse the repository at this point in the history
* Update dependency ruff to v0.2.2

* ruff

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Chris Talkington <[email protected]>
  • Loading branch information
renovate[bot] and ctalkington authored Feb 27, 2024
1 parent d211f8d commit 2822a2a
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 35 deletions.
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.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pylint = "3.1.0"
pytest = "7.4.2"
pytest-asyncio = "0.23.5"
pytest-cov = "4.1.0"
ruff = "0.0.275"
ruff = "0.2.2"
safety = "2.4.0b2"
types-cachetools = "^5.3.0"
yamllint = "1.32.0"
Expand Down
6 changes: 3 additions & 3 deletions src/pyipp/ipp.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ async def execute(
if parsed["status-code"] == IppStatus.ERROR_VERSION_NOT_SUPPORTED:
raise IPPVersionNotSupportedError("IPP version not supported by server")

if parsed["status-code"] not in range(0, 0x200):
if parsed["status-code"] not in range(0x200):
raise IPPError(
"Unexpected printer status code",
{"status-code": parsed["status-code"]},
Expand Down Expand Up @@ -237,10 +237,10 @@ async def printer(self) -> Printer:

return printer

async def __aenter__(self) -> IPP:
async def __aenter__(self) -> IPP: # noqa: PYI034
"""Async enter."""
return self

async def __aexit__(self, *_exec_info: Any) -> None:
async def __aexit__(self, *_exec_info: object) -> None:
"""Async exit."""
await self.close()
10 changes: 5 additions & 5 deletions src/pyipp/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ def from_dict(data: dict[str, Any]) -> Info:
manufacturer=make,
model=model,
printer_name=printer_name,
printer_info=data.get("printer-info", None),
printer_info=data.get("printer-info"),
printer_uri_supported=uri_supported,
serial=serial,
uptime=data.get("printer-up-time", 0),
uuid=uuid[9:] if uuid else None, # strip urn:uuid: from uuid
version=data.get("printer-firmware-string-version", None),
more_info=data.get("printer-more-info", None),
version=data.get("printer-firmware-string-version"),
more_info=data.get("printer-more-info"),
)


Expand Down Expand Up @@ -127,13 +127,13 @@ def from_dict(data: dict[str, Any]) -> State:
"""Return State object from IPP response."""
state = data.get("printer-state", 0)

if (reasons := data.get("printer-state-reasons", None)) == "none":
if (reasons := data.get("printer-state-reasons")) == "none":
reasons = None

return State(
printer_state=PRINTER_STATES.get(state, state),
reasons=reasons,
message=data.get("printer-state-message", None),
message=data.get("printer-state-message"),
)


Expand Down
2 changes: 1 addition & 1 deletion src/pyipp/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def parse_attribute( # noqa: PLR0912, PLR0915
)

raw_date = dict(
zip( # noqa: B905
zip(
(
"year",
"month",
Expand Down
10 changes: 5 additions & 5 deletions src/pyipp/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def construct_attribute(name: str, value: Any, tag: IppTag | None = None) -> byt
_LOGGER.debug("Unknown IppTag for %s", name)
return byte_str

if isinstance(value, (list, tuple, set)): # noqa: UP038
if isinstance(value, (list, tuple, set)):
for index, list_value in enumerate(value):
byte_str += struct.pack(">b", tag.value)

Expand All @@ -66,7 +66,7 @@ def encode_dict(data: dict[str, Any]) -> bytes:
version = data["version"] or DEFAULT_PROTO_VERSION
operation = data["operation"]

if (request_id := data.get("request-id", None)) is None:
if (request_id := data.get("request-id")) is None:
request_id = random.choice(range(10000, 99999)) # nosec # noqa: S311

encoded = struct.pack(">bb", *version)
Expand All @@ -75,17 +75,17 @@ def encode_dict(data: dict[str, Any]) -> bytes:

encoded += struct.pack(">b", IppTag.OPERATION.value)

if isinstance(data.get("operation-attributes-tag", None), dict):
if isinstance(data.get("operation-attributes-tag"), dict):
for attr, value in data["operation-attributes-tag"].items():
encoded += construct_attribute(attr, value)

if isinstance(data.get("job-attributes-tag", None), dict):
if isinstance(data.get("job-attributes-tag"), dict):
encoded += struct.pack(">b", IppTag.JOB.value)

for attr, value in data["job-attributes-tag"].items():
encoded += construct_attribute(attr, value)

if isinstance(data.get("printer-attributes-tag", None), dict):
if isinstance(data.get("printer-attributes-tag"), dict):
encoded += struct.pack(">b", IppTag.PRINTER.value)

for attr, value in data["printer-attributes-tag"].items():
Expand Down

0 comments on commit 2822a2a

Please sign in to comment.