Skip to content

Commit

Permalink
Merge pull request #358 from OpenTrafficCam/bug/5669-replace-types-al…
Browse files Browse the repository at this point in the history
…l-in-mypy-in-pre-commit-configyaml

Bug/5669 replace types all in mypy in pre commit configyaml
  • Loading branch information
briemla authored Sep 11, 2024
2 parents 1a2f232 + 145fb2f commit 1291745
Show file tree
Hide file tree
Showing 25 changed files with 206 additions and 35 deletions.
43 changes: 32 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,66 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.6.0
hooks:
- id: check-yaml
- id: check-json
- id: end-of-file-fixer
exclude_types: [json]
exclude_types:
- json
- id: trailing-whitespace
- id: no-commit-to-branch
- id: debug-statements
- id: requirements-txt-fixer
- id: check-executables-have-shebangs
- id: detect-private-key
- repo: local
hooks:
- id: update-type-stubs
name: Check for Type Stubs and Update Config
entry: ./update_precommit.py
language: system
files: ^requirements.*\.txt$
stages:
- commit
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: ["--profile", "black"]
args:
- --profile
- black
- repo: https://github.com/psf/black
rev: 23.10.0
rev: 24.8.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.6.1
rev: v1.11.1
hooks:
- id: mypy
entry: mypy .
additional_dependencies: [types-all, pydantic]
additional_dependencies:
- types-PyYAML
- types-flake8
- types-jsonschema
- types-psutil
- types-seaborn
- types-setuptools
- types-tqdm
- types-ujson
always_run: true
pass_filenames: false
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.32.0
rev: v1.35.1
hooks:
- id: yamllint
args: [-c=./.yamllint.yaml]
args:
- -c=./.yamllint.yaml
- repo: https://github.com/koalaman/shellcheck-precommit
rev: v0.9.0
rev: v0.10.0
hooks:
- id: shellcheck
1 change: 1 addition & 0 deletions OTVision/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision init module
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision config module for setting default values
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/convert/convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision main module for converting videos to other formats and frame rates.
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/detect/detect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision main module to detect objects in single or multiple images or videos.
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
3 changes: 2 additions & 1 deletion OTVision/helpers/formats.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision helpers to change formats and retrieve information
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down Expand Up @@ -93,7 +94,7 @@ def _get_time_from_frame_number(
fps: int,
return_yyyymmdd_hhmmss: bool = True,
return_milliseconds: bool = True,
) -> pd.Series:
) -> pd.Series | tuple[pd.Series, pd.Series]:
"""Get datetime series of detections from series of frame numbers of video
the objects were detected using a start datetime of the video and
the video frame rate (fps).
Expand Down
1 change: 1 addition & 0 deletions OTVision/helpers/log.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision helpers for logging
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/helpers/machine.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision helpers to gather information about the machine and the system
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/track/iou_util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Utils for using iou tracker
"""

# ---------------------------------------------------------
# IOU Tracker
# Copyright (c) 2017 TU Berlin, Communication Systems Group
Expand Down
7 changes: 4 additions & 3 deletions OTVision/transform/get_homography.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision module for calculating a homography from reference points
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down Expand Up @@ -111,15 +112,15 @@ def get_homography(


def evaluate_homography(
refpts_pixel: dict,
refpts_pixel: np.ndarray,
refpts_world_upshifted_disassembled: np.ndarray,
homography_matrix: np.ndarray,
) -> dict: # TODO: Type hint nested dict during refactoring
"""Calculates transformation error of homography
Args:
refpts_pixel (dict): Reference points in both pixel and utm coordinates
refpts_world_upshifted_disassembled (ndarry): Internal variable
refpts_pixel (ndarray): Reference points in both pixel and utm coordinates
refpts_world_upshifted_disassembled (ndarray): Internal variable
homography_matrix (ndarray): Homography matrix
Returns:
Expand Down
1 change: 1 addition & 0 deletions OTVision/transform/reference_points_picker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
OTVision tool to select reference points for transformation
from pixel to world coordinates
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/transform/transform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision main module for transforming tracks from pixel to world coordinates
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/view/view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision main gui module
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/view/view_convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision gui module for convert.py
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/view/view_detect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision gui module for detect.py
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
25 changes: 13 additions & 12 deletions OTVision/view/view_helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision helper gui module
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down Expand Up @@ -253,19 +254,19 @@ def update_tree_files(self):
def update_other_gui_parts(self):
# Activate/deactivate buttons in FrameTransform
if self.files_dict:
self.master.frame_transform.frame_options.button_choose_refpts[
"state"
] = tk.NORMAL
self.master.frame_transform.frame_options.button_click_refpts[
"state"
] = tk.NORMAL
self.master.frame_transform.frame_options.button_choose_refpts["state"] = (
tk.NORMAL
)
self.master.frame_transform.frame_options.button_click_refpts["state"] = (
tk.NORMAL
)
else:
self.master.frame_transform.frame_options.button_choose_refpts[
"state"
] = tk.DISABLED
self.master.frame_transform.frame_options.button_click_refpts[
"state"
] = tk.DISABLED
self.master.frame_transform.frame_options.button_choose_refpts["state"] = (
tk.DISABLED
)
self.master.frame_transform.frame_options.button_click_refpts["state"] = (
tk.DISABLED
)

def get_tree_files(self):
return [
Expand Down
1 change: 1 addition & 0 deletions OTVision/view/view_track.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision gui module for track.py
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions OTVision/view/view_transform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision gui module for transform.py
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision script to call the convert main with arguments parsed from command line
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions detect.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision script to call the detect main with arguments parsed from command line
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
17 changes: 9 additions & 8 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
-r requirements.txt
black==24.4.0
black==24.8.0
coremltools==7.2; sys_platform == 'darwin'
flake8==7.0.0
flake8==7.1.1
interrogate==1.5.0
isort==5.12.0
isort==5.13.2
jsonschema==4.23.0
mypy==1.6.1
pre-commit==3.6.0
pytest==8.0.0
pytest-cov==4.1.0
yamllint==1.33.0
mypy==1.11.1
pandas-stubs==2.2.2.240807
pre-commit==3.8.0
pytest==8.3.2
pytest-cov==5.0.0
yamllint==1.35.1
1 change: 1 addition & 0 deletions track.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision script to call the track main with arguments parsed from command line
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions transform.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
OTVision script to call the transform main with arguments parsed from command line
"""

# Copyright (C) 2022 OpenTrafficCam Contributors
# <https://github.com/OpenTrafficCam
# <[email protected]>
Expand Down
Loading

0 comments on commit 1291745

Please sign in to comment.