Skip to content

Commit

Permalink
Merge pull request #689 from chinapandaman/PPF-688
Browse files Browse the repository at this point in the history
PPF-688: add new linters
  • Loading branch information
chinapandaman authored Jul 11, 2024
2 parents 303b773 + c037287 commit 3ed3419
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/python-linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ jobs:
- name: Analyze code with pylint
run: |
pylint PyPDFForm
- name: Analyze code with pyright
run: |
pyright .
- name: Analyze code with ruff
run: |
ruff check .
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ test-all:
coverage-all:
bash ./scripts/coverage.sh

check-imports:
bash ./scripts/check_imports.sh
linting:
bash ./scripts/linting.sh

generate-new-pdf-samples:
bash ./scripts/new_pdf_samples.sh
Expand Down
2 changes: 2 additions & 0 deletions PyPDFForm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
__version__ = "1.4.30"

from .wrapper import FormWrapper, PdfWrapper

__all__ = ["FormWrapper", "PdfWrapper"]
1 change: 1 addition & 0 deletions PyPDFForm/middleware/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(
) -> None:
"""Constructs basic attributes for the object."""

super().__init__()
self._name = name
self.value = value

Expand Down
2 changes: 1 addition & 1 deletion PyPDFForm/middleware/checkbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def schema_definition(self) -> dict:
return {"type": "boolean"}

@property
def sample_value(self) -> bool:
def sample_value(self) -> Union[bool, int]:
"""Sample value of the checkbox."""

return True
Expand Down
1 change: 1 addition & 0 deletions PyPDFForm/widgets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(
) -> None:
"""Sets acro form parameters."""

super().__init__()
self.page_number = page_number
self.acro_form_params = {
"name": name,
Expand Down
1 change: 1 addition & 0 deletions PyPDFForm/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(
) -> None:
"""Constructs all attributes for the object."""

super().__init__()
self.stream = fp_or_f_obj_or_stream_to_stream(template)

def read(self) -> bytes:
Expand Down
17 changes: 17 additions & 0 deletions pyrightconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"typeCheckingMode": "basic",
"reportArgumentType": "none",
"reportAssignmentType": "none",
"reportAttributeAccessIssue": "none",
"reportReturnType": "none",
"reportOptionalSubscript": "none",
"reportIndexIssue": "none",
"reportOperatorIssue": "none",
"reportGeneralTypeIssues": "none",
"reportOptionalMemberAccess": "none",
// custom configs
"reportPossiblyUnboundVariable": "error",
"reportUnusedImport": "error",
"reportIncompatibleMethodOverride": "error",
"reportMissingSuperCall": "error"
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ pillow
pudb
pylint
pypdf
pyright
pytest
reportlab
requests
ruff
2 changes: 2 additions & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[lint]
select = ["E4", "E7", "E9", "F", "N802"]
6 changes: 0 additions & 6 deletions scripts/check_imports.sh

This file was deleted.

7 changes: 7 additions & 0 deletions scripts/linting.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if [[ "$VIRTUAL_ENV" == "" ]]; then
source "./venv/bin/activate"
fi

pylint PyPDFForm/
pyright .
ruff check .

0 comments on commit 3ed3419

Please sign in to comment.