Skip to content

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
felixdittrich92 committed Nov 16, 2024
1 parent c79b8a4 commit d0f0b84
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: no-commit-to-branch
args: ['--branch', 'main']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.1
rev: v0.7.4
hooks:
- id: ruff
args: [ --fix ]
Expand Down
4 changes: 2 additions & 2 deletions doctr/models/kie_predictor/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def __init__(
**kwargs: Any,
) -> None:
nn.Module.__init__(self)
self.det_predictor = det_predictor.eval() # type: ignore[attr-defined]
self.reco_predictor = reco_predictor.eval() # type: ignore[attr-defined]
self.det_predictor = det_predictor.eval()
self.reco_predictor = reco_predictor.eval()
_KIEPredictor.__init__(
self,
assume_straight_pages,
Expand Down
2 changes: 1 addition & 1 deletion doctr/models/kie_predictor/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __call__(
origin_page_shapes = [page.shape[:2] for page in pages]

# Forward again to get predictions on straight pages
loc_preds = self.det_predictor(pages, **kwargs) # type: ignore[assignment]
loc_preds = self.det_predictor(pages, **kwargs)

dict_loc_preds: Dict[str, List[np.ndarray]] = invert_data_structure(loc_preds) # type: ignore

Expand Down
4 changes: 2 additions & 2 deletions doctr/models/predictor/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def __init__(
**kwargs: Any,
) -> None:
nn.Module.__init__(self)
self.det_predictor = det_predictor.eval() # type: ignore[attr-defined]
self.reco_predictor = reco_predictor.eval() # type: ignore[attr-defined]
self.det_predictor = det_predictor.eval()
self.reco_predictor = reco_predictor.eval()
_OCRPredictor.__init__(
self,
assume_straight_pages,
Expand Down
4 changes: 2 additions & 2 deletions doctr/models/predictor/tensorflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ def __call__(
origin_page_shapes = [page.shape[:2] for page in pages]

# forward again to get predictions on straight pages
loc_preds_dict = self.det_predictor(pages, **kwargs) # type: ignore[assignment]
loc_preds_dict = self.det_predictor(pages, **kwargs)

assert all(len(loc_pred) == 1 for loc_pred in loc_preds_dict), (
"Detection Model in ocr_predictor should output only one class"
)
loc_preds: List[np.ndarray] = [list(loc_pred.values())[0] for loc_pred in loc_preds_dict] # type: ignore[union-attr]
loc_preds: List[np.ndarray] = [list(loc_pred.values())[0] for loc_pred in loc_preds_dict]
# Detach objectness scores from loc_preds
loc_preds, objectness_scores = detach_scores(loc_preds)

Expand Down
2 changes: 1 addition & 1 deletion doctr/models/recognition/predictor/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def forward(
crops = new_crops

# Resize & batch them
processed_batches = self.pre_processor(crops)
processed_batches = self.pre_processor(crops) # type: ignore[arg-type]

# Forward it
_params = next(self.model.parameters())
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ select = [
"E", "W", "F", "I", "N", "Q", "C4", "T10", "LOG",
"D101", "D103", "D201","D202","D207","D208","D214","D215","D300","D301","D417", "D419", "D207" # pydocstyle
]
ignore = ["E402", "E203", "F403", "E731", "N812", "N817", "C408"]
ignore = ["E402", "E203", "F403", "E731", "N812", "N817", "C408", "LOG015"]

[tool.ruff.lint.isort]
known-first-party = ["doctr", "app", "utils"]
Expand Down

0 comments on commit d0f0b84

Please sign in to comment.