Skip to content

Commit

Permalink
refactor: run mypy checks 🐍
Browse files Browse the repository at this point in the history
  • Loading branch information
KarelZe committed Jan 8, 2024
1 parent 9ec6b93 commit 5ffc34d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ repos:
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
- id: mypy
# yaml requires additional stubs.
# Similar to: https://stackoverflow.com/a/73603491/5755604
additional_dependencies: ['types-PyYAML']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
hooks:
Expand Down
2 changes: 2 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[mypy]
exclude = "utils/ccl_chrome_indexeddb/*.py"
30 changes: 22 additions & 8 deletions utils/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,23 @@
import click
from bs4 import BeautifulSoup
from consts import XTRACT_HEADER
from dataclasses_json import LetterCase, Undefined, config, dataclass_json
from dataclasses_json import (
DataClassJsonMixin,
LetterCase,
Undefined,
config,
)
from shared import parse_db, write_results_to_json

CAMEL_CASE_CONFIG = config(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)[
"dataclasses_json"
]


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass()
class Meeting:
class Meeting(DataClassJsonMixin):
dataclass_json_config = CAMEL_CASE_CONFIG

client_update_time: Optional[str] = None
cached_deduplication_key: Optional[str] = None
id: Optional[str] = None
Expand All @@ -37,9 +47,10 @@ def __lt__(self, other):
return self.cached_deduplication_key < other.cached_deduplication_key


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass()
class Message:
class Message(DataClassJsonMixin):
dataclass_json_config = CAMEL_CASE_CONFIG

attachments: list[Any] = field(default_factory=list)
cached_deduplication_key: Optional[str] = None
client_arrival_time: Optional[str] = None
Expand All @@ -66,7 +77,9 @@ class Message:

def __post_init__(self):
if self.cached_deduplication_key is None:
self.cached_deduplication_key = self.creator + self.clientmessageid
self.cached_deduplication_key = str(self.creator) + str(
self.clientmessageid
)

def __eq__(self, other):
return (
Expand All @@ -81,9 +94,10 @@ def __lt__(self, other):
return self.cached_deduplication_key < other.cached_deduplication_key


@dataclass_json(letter_case=LetterCase.CAMEL, undefined=Undefined.EXCLUDE)
@dataclass()
class Contact:
class Contact(DataClassJsonMixin):
dataclass_json_config = CAMEL_CASE_CONFIG

display_name: Optional[str] = None
email: Optional[str] = None
mri: Optional[str] = field(default=None, compare=True)
Expand Down

0 comments on commit 5ffc34d

Please sign in to comment.