Skip to content

Commit

Permalink
DEV: ruff updates; activate --fix (#1747)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma authored Mar 26, 2023
1 parent c75bb16 commit 2205e9f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ repos:
additional_dependencies: [black==22.1.0]
exclude: "docs/user/robustness.md"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.254'
rev: 'v0.0.259'
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
Expand Down
2 changes: 1 addition & 1 deletion pypdf/_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
except ImportError:
# PEP 586 introduced typing.Literal with Python 3.8
# For older Python versions, the backport typing_extensions is necessary:
from typing_extensions import Literal # type: ignore[misc]
from typing_extensions import Literal # type: ignore[misc, assignment]

# ref: pdf1.8 spec section 3.5.2 algorithm 3.2
_encryption_padding = (
Expand Down
2 changes: 1 addition & 1 deletion pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
except ImportError:
# PEP 586 introduced typing.Literal with Python 3.8
# For older Python versions, the backport typing_extensions is necessary:
from typing_extensions import Literal # type: ignore[misc]
from typing_extensions import Literal # type: ignore[misc, assignment]


def decompress(data: bytes) -> bytes:
Expand Down
2 changes: 1 addition & 1 deletion pypdf/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Python 3.8+: https://peps.python.org/pep-0586
from typing import Literal # type: ignore[attr-defined]
except ImportError:
from typing_extensions import Literal # type: ignore[misc]
from typing_extensions import Literal # type: ignore[misc, assignment]

try:
# Python 3.10+: https://www.python.org/dev/peps/pep-0484/
Expand Down
2 changes: 1 addition & 1 deletion pypdf/xmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def __init__(self, stream: ContentStream) -> None:
self.stream = stream
try:
data = self.stream.get_data()
doc_root: Document = parseString(data)
doc_root: Document = parseString(data) # noqa: S318
except ExpatError as e:
raise PdfReadError(f"XML in XmpInformation was invalid: {e}")
self.rdf_root: XmlElement = doc_root.getElementsByTagNameNS(
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ ignore = [
"RUF001", "RUF002", "RUF005",
"ARG",
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` is necessary
"PLC",
# Personal preference
"D406", # Section name should end with a newline ("Returns")
"D212", # I want multiline-docstrings to start at the second line
Expand Down Expand Up @@ -149,6 +150,7 @@ ignore = [
"UP006", "UP007",
# for the moment, fix it later:
"A", # Variable is shadowing a built-in
"B028", # No explicit `stacklevel` keyword argument found
"B904", # Within an `except` clause, raise exceptions with
"B905", # `zip()` without an explicit `strict=` parameter
"C901",
Expand Down Expand Up @@ -177,7 +179,7 @@ ignore = [
[tool.ruff.per-file-ignores]
"tests/*" = ["S101", "ANN001", "ANN201","D104", "S105", "S106"]
"sample-files/*" = ["D100", "INP001"]
"_encryption.py" = ["S324"]
"_encryption.py" = ["S324", "S311"]
"_security.py" = ["S324"]
"_writer.py" = ["S324"]
"make_changelog.py" = ["T201"]
Expand Down
41 changes: 18 additions & 23 deletions requirements/ci-3.11.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,48 @@
#
# pip-compile --output-file=requirements/ci-3.11.txt requirements/ci.in
#
attrs==22.1.0
attrs==22.2.0
# via
# flake8-bugbear
# flake8-implicit-str-concat
# pytest
coverage==6.5.0
coverage==7.2.2
# via -r requirements/ci.in
flake8==5.0.4
flake8==6.0.0
# via
# -r requirements/ci.in
# flake8-bugbear
# flake8-print
flake8-bugbear==22.10.27
flake8-bugbear==23.3.23
# via -r requirements/ci.in
flake8-implicit-str-concat==0.3.0
flake8-implicit-str-concat==0.4.0
# via -r requirements/ci.in
flake8-print==5.0.0
# via -r requirements/ci.in
iniconfig==1.1.1
iniconfig==2.0.0
# via pytest
mccabe==0.7.0
# via flake8
more-itertools==8.14.0
# via flake8-implicit-str-concat
mypy==0.982
mypy==1.1.1
# via -r requirements/ci.in
mypy-extensions==0.4.3
mypy-extensions==1.0.0
# via mypy
packaging==21.3
packaging==23.0
# via pytest
pillow==9.3.0
pillow==9.4.0
# via -r requirements/ci.in
pluggy==1.0.0
# via pytest
py-cpuinfo==9.0.0
# via pytest-benchmark
pycodestyle==2.9.1
pycodestyle==2.10.0
# via
# flake8
# flake8-print
pycryptodome==3.15.0
pycryptodome==3.17
# via -r requirements/ci.in
pyflakes==2.5.0
pyflakes==3.0.1
# via flake8
pyparsing==3.0.9
# via packaging
pytest==7.2.0
pytest==7.2.2
# via
# -r requirements/ci.in
# pytest-benchmark
Expand All @@ -59,13 +54,13 @@ pytest-benchmark==4.0.0
# via -r requirements/ci.in
pytest-socket==0.6.0
# via -r requirements/ci.in
ruff==0.0.254
ruff==0.0.259
# via -r requirements/ci.in
typeguard==2.13.3
typeguard==3.0.2
# via -r requirements/ci.in
types-dataclasses==0.6.6
# via -r requirements/ci.in
types-pillow==9.2.2.2
types-pillow==9.4.0.17
# via -r requirements/ci.in
typing-extensions==4.4.0
typing-extensions==4.5.0
# via mypy
6 changes: 3 additions & 3 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ def get_pdf_from_url(url: str, name: str) -> bytes:
cpt = 3
while cpt > 0:
try:
with urllib.request.urlopen(url) as response, cache_path.open(
"wb"
) as out_file:
with urllib.request.urlopen( # noqa: S310
url
) as response, cache_path.open("wb") as out_file:
out_file.write(response.read())
cpt = 0
except HTTPError as e:
Expand Down

0 comments on commit 2205e9f

Please sign in to comment.