Skip to content

Commit

Permalink
MAINT: Remove unnecessary decorator + mypy fixes
Browse files Browse the repository at this point in the history
While on it, pre-commit was also updated

Taken from #2086

Co-authored-by: Lucas Cimon <[email protected]>
  • Loading branch information
MartinThoma and Lucas-C committed Aug 19, 2023
1 parent 0d3dded commit 755df8f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@ repos:
- id: black
args: [--target-version, py36]
- repo: https://github.com/asottile/blacken-docs
rev: 1.15.0
rev: 1.16.0
hooks:
- id: blacken-docs
additional_dependencies: [black==22.1.0]
exclude: "docs/user/robustness.md"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.280'
rev: 'v0.0.285'
hooks:
- id: ruff
args: ['--fix']
- repo: https://github.com/asottile/pyupgrade
rev: v3.9.0
rev: v3.10.1
hooks:
- id: pyupgrade
args: [--py36-plus]
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
rev: 6.1.0
hooks:
- id: flake8
args: ["--ignore", "E,W,F"]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v1.4.1'
rev: 'v1.5.1'
hooks:
- id: mypy
files: ^pypdf/.*
Expand Down
2 changes: 1 addition & 1 deletion pypdf/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def decode(
return tiff_header + data


def decode_stream_data(stream: Any) -> Union[str, bytes]: # utils.StreamObject
def decode_stream_data(stream: Any) -> bytes: # utils.StreamObject
"""
Decode the stream data based on the specified filters.

Expand Down
10 changes: 1 addition & 9 deletions pypdf/generic/_data_structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,7 @@ def _reset_node_tree_relationship(child_obj: Any) -> None:

class StreamObject(DictionaryObject):
def __init__(self) -> None:
self.__data: Optional[str] = None
self._data: bytes = b""
self.decoded_self: Optional[DecodedStreamObject] = None

def _clone(
Expand Down Expand Up @@ -833,14 +833,6 @@ def decodedSelf(self, value: "DecodedStreamObject") -> None: # deprecated
deprecation_with_replacement("decodedSelf", "decoded_self", "3.0.0")
self.decoded_self = value

@property
def _data(self) -> Any:
return self.__data

@_data.setter
def _data(self, value: Any) -> None:
self.__data = value

def write_to_stream(
self, stream: StreamType, encryption_key: Union[None, str, bytes] = None
) -> None:
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ ignore = [
"PD011", # Use `.to_numpy()` instead of `.values`
"FA102", # Missing `from __future__ import annotations`, but uses PEP 604 union
"PERF203", # `try`-`except` within a loop incurs performance overhead
"PYI042", # Type alias `mode_str_type` should be CamelCase
# Ruff bug
"PT014", # Duplicate of test case at index 1 in `@pytest_mark.parametrize`
]

[tool.ruff.per-file-ignores]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class Tst: # to replace pdf
# TODO: What should happen with the stream?
assert do == {"/S": "/GoTo"}
if length in (6, 10):
assert b"BT /F1" in do._StreamObject__data
assert b"BT /F1" in do._data
raise PdfReadError("__ALLGOOD__")
assert should_fail ^ (exc.value.args[0] == "__ALLGOOD__")

Expand Down

0 comments on commit 755df8f

Please sign in to comment.