diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 970c5d3..163716f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,75 +4,17 @@ exclude: | version.py| conftest.py ) -repos: - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.5.0 - hooks: - - id: trailing-whitespace - - id: end-of-file-fixer - - id: check-yaml - args: ["--unsafe"] - - id: check-added-large-files - - - repo: https://github.com/myint/autoflake - rev: v2.2.1 - hooks: - - id: autoflake - name: Cleanup imports - args: - - --in-place - - --remove-all-unused-imports - - --expand-star-imports - - --ignore-init-module-imports - - - repo: https://github.com/pre-commit/mirrors-isort - rev: v5.10.1 - hooks: - - id: isort - name: Sorts imports - args: [ - # Align isort with black formatting - "--multi-line=3", - "--trailing-comma", - "--force-grid-wrap=0", - "--use-parentheses", - "--line-width=99", - ] - - repo: https://github.com/psf/black - rev: 23.12.1 - hooks: - - id: black - name: Fixes formatting - language_version: python3 - args: ["--line-length=99"] - - - repo: https://github.com/PyCQA/flake8 - rev: 6.1.0 - hooks: - - id: flake8 - name: Checks pep8 style - args: - - --max-line-length=99 - # F405 - init imports * from module - # F401 - ignore imports used in init - # F403 - import * used in init - - --exclude=__init__.py - # ignore long comments (E501), as long lines are formatted by black - # ignore Whitespace before ':' (E203) - # ignore Line break occurred before a binary operator (W503) - # ignore module level import not at top of file (E402) to skip tests with uninstalled modules (pytest.importorskip) - - --ignore=E501,E203,W503,E402 - - - repo: https://github.com/PyCQA/pydocstyle - rev: 6.3.0 +repos: + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.13 hooks: - - id: pydocstyle - name: docstrings - entry: pydocstyle - language: python - args: - - --ignore=D100,D203,D405,D407,D213,D413 + # Run the linter. + - id: ruff + args: [ --fix ] + # Run the formatter. + - id: ruff-format - repo: local hooks: diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..7e42192 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1 @@ +line-length = 99 diff --git a/requirements.dev.txt b/requirements.dev.txt index 3aaf5e0..4c5ac24 100644 --- a/requirements.dev.txt +++ b/requirements.dev.txt @@ -58,9 +58,9 @@ google-api-core==2.15.0 # via # -r requirements.txt # google-api-python-client -google-api-python-client==2.111.0 +google-api-python-client==2.113.0 # via -r requirements.txt -google-auth==2.25.2 +google-auth==2.26.2 # via # -r requirements.txt # google-api-core @@ -90,11 +90,11 @@ iniconfig==2.0.0 # via pytest isort==5.13.2 # via pylint -jinja2==3.1.2 +jinja2==3.1.3 # via mkdocs lazydocs==0.4.8 # via -r requirements.dev.in -markdown==3.5.1 +markdown==3.5.2 # via mkdocs markupsafe==2.1.3 # via @@ -138,7 +138,7 @@ pluggy==1.3.0 # via pytest pre-commit==3.6.0 # via -r requirements.dev.in -protobuf==4.25.1 +protobuf==4.25.2 # via # -r requirements.txt # google-api-core @@ -172,7 +172,7 @@ pyparsing==3.1.1 # httplib2 pyproject-hooks==1.0.0 # via build -pytest==7.4.3 +pytest==7.4.4 # via # -r requirements.dev.in # pytest-cov diff --git a/requirements.txt b/requirements.txt index d84de85..22c010e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,9 +16,9 @@ charset-normalizer==3.3.2 # via requests google-api-core==2.15.0 # via google-api-python-client -google-api-python-client==2.111.0 +google-api-python-client==2.113.0 # via -r requirements.in -google-auth==2.25.2 +google-auth==2.26.2 # via # google-api-core # google-api-python-client @@ -37,7 +37,7 @@ idna==3.6 # via requests oauth2client==4.1.3 # via -r requirements.in -protobuf==4.25.1 +protobuf==4.25.2 # via # google-api-core # googleapis-common-protos diff --git a/src/action.py b/src/action.py index 590df62..d139807 100644 --- a/src/action.py +++ b/src/action.py @@ -142,7 +142,9 @@ def action(self, button: str, dry_run: bool = False) -> None: traceback.print_exception(*sys.exc_info()) def ifttt_action( - self, button: str, action_params: models.IftttAction # pylint: disable=unused-argument + self, + button: str, # pylint: disable=unused-argument + action_params: models.IftttAction, ) -> None: """Register event in IFTTT.""" ifttt = Ifttt(self.settings) @@ -155,21 +157,27 @@ def ifttt_action( ) def openhab_action( - self, button: str, action_params: models.OpenhabAction # pylint: disable=unused-argument + self, + button: str, # pylint: disable=unused-argument + action_params: models.OpenhabAction, ) -> None: """Register event in OpenHab.""" openhab = OpenHab(self.settings) openhab.press(action_params) def calendar_action( - self, button: str, action_params: models.CalendarAction # pylint: disable=unused-argument + self, + button: str, # pylint: disable=unused-argument + action_params: models.CalendarAction, ) -> None: """Register event in Google Calendar.""" calendar = Calendar(self.settings, action_params.calendar_id) self.event(calendar, action_params) def sheet_action( - self, button: str, action_params: models.SheetAction # pylint: disable=unused-argument + self, + button: str, # pylint: disable=unused-argument + action_params: models.SheetAction, ) -> None: """Register event in Google Sheet.""" sheet = Sheet( diff --git a/src/google_calendar.py b/src/google_calendar.py index 5004211..c78f4c8 100644 --- a/src/google_calendar.py +++ b/src/google_calendar.py @@ -121,7 +121,8 @@ def get_last_event(self, summary: str) -> Tuple[Optional[str], Optional[List[Any def delete_event(self, event_id: str) -> None: """Delete event from Google Calendar.""" self.service().events().delete( - calendarId=self.calendarId, eventId=event_id # 'primary', + calendarId=self.calendarId, + eventId=event_id, # 'primary', ).execute() def close_event(self, event_id: Union[int, str], close_time: datetime.datetime) -> None: