From b5bd3615695c49607c0c2984c72bc48b086666f6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 11 Dec 2023 01:14:58 +0100 Subject: [PATCH 1/4] wip pre-commit config --- .pre-commit-config.yaml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .pre-commit-config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..4eca63b --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,27 @@ +repos: + - repo: local + hooks: + # - id: whitespace + # name: strip whitespace + # entry: ./strip_whitespace.sh + # language: system + # always_run: true + # pass_filenames: false + - id: ruff + name: ruff + entry: python -m ruff . --preview + language: system + always_run: true + pass_filenames: false + - id: mypy + name: mypy + entry: mypy pytest_abra/ + language: system + always_run: true + pass_filenames: false + - id: tests + name: run all tests that are not marked slow + entry: pytest -m "not slow" + language: system + always_run: true + pass_filenames: false From 5a45255bd6c6bc1640545f671c623c3f2d3ca057 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 11 Dec 2023 01:25:47 +0100 Subject: [PATCH 2/4] test --- .pre-commit-config.yaml | 47 ++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4eca63b..2b2ef57 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,27 +1,36 @@ repos: - - repo: local - hooks: + # - repo: local + # hooks: # - id: whitespace # name: strip whitespace # entry: ./strip_whitespace.sh # language: system # always_run: true # pass_filenames: false + + # - id: mypy + # name: mypy + # entry: mypy pytest_abra/ + # language: system + # always_run: true + # pass_filenames: false + # - id: tests + # name: run all tests that are not marked slow + # entry: pytest -m "not slow" + # language: system + # always_run: true + # pass_filenames: false + + - repo: https://github.com/pre-commit/mirrors-mypy + rev: '' # Use the sha / tag you want to point at + hooks: + - id: mypy + + - repo: https://github.com/astral-sh/ruff-pre-commit + # Ruff version. + rev: v0.1.7 + hooks: + # Run the linter. - id: ruff - name: ruff - entry: python -m ruff . --preview - language: system - always_run: true - pass_filenames: false - - id: mypy - name: mypy - entry: mypy pytest_abra/ - language: system - always_run: true - pass_filenames: false - - id: tests - name: run all tests that are not marked slow - entry: pytest -m "not slow" - language: system - always_run: true - pass_filenames: false + # Run the formatter. + - id: ruff-format \ No newline at end of file From 8ba0121415a783a23c20982704994637e1f602a7 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 11 Dec 2023 01:27:00 +0100 Subject: [PATCH 3/4] add working config --- .pre-commit-config.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b2ef57..b7c3d03 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,6 @@ repos: - id: mypy - repo: https://github.com/astral-sh/ruff-pre-commit - # Ruff version. rev: v0.1.7 hooks: # Run the linter. From ba33d97c536adb014cb55a10276bc0a242c4314e Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 11 Dec 2023 01:44:02 +0100 Subject: [PATCH 4/4] fix type and config for tests --- .pre-commit-config.yaml | 29 +++++++++-------------------- pytest_abra/custom_fixtures.py | 10 +++++----- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index b7c3d03..fabed9e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,30 +1,19 @@ repos: # - repo: local - # hooks: - # - id: whitespace - # name: strip whitespace - # entry: ./strip_whitespace.sh - # language: system - # always_run: true - # pass_filenames: false - - # - id: mypy - # name: mypy - # entry: mypy pytest_abra/ - # language: system - # always_run: true - # pass_filenames: false - # - id: tests - # name: run all tests that are not marked slow - # entry: pytest -m "not slow" - # language: system - # always_run: true - # pass_filenames: false + # hooks: + # - id: tests + # name: run all tests that are not marked slow + # entry: python -m pytest -m "not slow" + # language: system + # language_version: default + # always_run: true + # pass_filenames: false - repo: https://github.com/pre-commit/mirrors-mypy rev: '' # Use the sha / tag you want to point at hooks: - id: mypy + args: [--ignore-missing-imports] - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.7 diff --git a/pytest_abra/custom_fixtures.py b/pytest_abra/custom_fixtures.py index c5e8b6c..972b07e 100644 --- a/pytest_abra/custom_fixtures.py +++ b/pytest_abra/custom_fixtures.py @@ -3,7 +3,8 @@ import os import re -from datetime import datetime, timedelta + +# from datetime import datetime, timedelta from pathlib import Path from typing import Generator, Protocol, TypedDict @@ -93,7 +94,7 @@ def URL(env_config: dict[str, str]) -> BaseUrl: @pytest.fixture(scope="session") -def imap_client() -> Generator[Imbox]: +def imap_client() -> Generator[Imbox, None, None]: """imap email client using credentials from environment variables""" assert os.environ["IMAP_HOST"] @@ -138,9 +139,8 @@ def imap_recent_messages(imap_client: Imbox) -> list[Message]: for uid, message in messages: print(uid, message.subject, message.date)""" - N_MINUTES = 30 - - n_minutes_ago = datetime.now() - timedelta(minutes=N_MINUTES) + # N_MINUTES = 30 + # n_minutes_ago = datetime.now() - timedelta(minutes=N_MINUTES) uids: list[bytes] = [] messages: list[Message] = [] # for uid, message in imap_client.messages(date__gt=n_minutes_ago):