summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJordan Cook <jordan.cook@pioneer.com>2021-09-08 17:02:17 -0500
committerJordan Cook <jordan.cook@pioneer.com>2021-09-08 17:25:34 -0500
commitd1cedec14974f76724aeaf85779fc7c8911812e3 (patch)
tree2c9ae989dd61c0af36fc6173f3c7830c3de0c04c
parentef6d9013e34712973af73e58a97ef9eb60a904bd (diff)
downloadrequests-cache-d1cedec14974f76724aeaf85779fc7c8911812e3.tar.gz
Re-enable mypy pre-commit hook with attrs as an explicit hook dependency for correct mypy-attrs behavior
-rw-r--r--.github/workflows/build.yml21
-rw-r--r--.pre-commit-config.yaml13
-rw-r--r--noxfile.py6
-rw-r--r--pyproject.toml3
-rw-r--r--requests_cache/backends/filesystem.py6
5 files changed, 13 insertions, 36 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index b9e8dbf..1d7ca42 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -89,24 +89,3 @@ jobs:
python-version: ${{ env.LATEST_PY_VERSION }}
- name: Run style checks & linting
uses: pre-commit/action@v2.0.3
-
- # TODO: This section could be removed if the issues with the mypy pre-commit hook were resolved
- - uses: snok/install-poetry@v1.2
- with:
- version: 1.2.0a2
- virtualenvs-in-project: true
- - name: Cache python packages
- id: cache
- uses: actions/cache@v2
- with:
- path: .venv
- key: venv-${{ matrix.python-version }}-latest-${{ hashFiles('poetry.lock') }}
- - name: Install dependencies
- if: steps.cache.outputs.cache-hit != 'true'
- run: poetry install -v -E all
- - name: Run type checking
- run: >
- poetry run mypy
- --install-types --non-interactive
- --ignore-missing-imports
- requests_cache
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 8536c56..29ff89d 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -25,13 +25,12 @@ repos:
hooks:
- id: flake8
additional_dependencies: [flake8-comprehensions]
- # TODO: This is currently failing for attrs classes in CI, but passes locally. Mypy run without pre-commit also passes.
- # - repo: https://github.com/pre-commit/mirrors-mypy
- # rev: v0.910
- # hooks:
- # - id: mypy
- # files: requests_cache
- # additional_dependencies: [types-itsdangerous, types-requests, types-pyyaml, types-redis, types-ujson]
+ - repo: https://github.com/pre-commit/mirrors-mypy
+ rev: v0.910
+ hooks:
+ - id: mypy
+ files: requests_cache
+ additional_dependencies: [attrs, types-itsdangerous, types-requests, types-pyyaml, types-redis, types-ujson]
- repo: https://github.com/yunojuno/pre-commit-xenon
rev: v0.1
hooks:
diff --git a/noxfile.py b/noxfile.py
index de970b7..941b945 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -77,7 +77,5 @@ def livedocs(session):
@session(python=False)
def lint(session):
"""Run linters and code formatters via pre-commit"""
- cmd_1 = 'pre-commit run --all-files'
- cmd_2 = 'mypy --install-types --non-interactive requests_cache'
- session.run(*cmd_1.split(' '))
- session.run(*cmd_2.split(' '))
+ cmd = 'pre-commit run --all-files'
+ session.run(*cmd.split(' '))
diff --git a/pyproject.toml b/pyproject.toml
index 37b1ac8..ef510d9 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -92,8 +92,7 @@ requests-mock = "^1.8"
responses = "0.10.15"
timeout-decorator = "^0.5"
-# For linting, etc.; additional tools are managed by pre-commit
-mypy = "^0.910"
+# Tools for linting, type checking, etc. are managed with pre-commit
pre-commit = "^2.15"
# For convenience in local development
diff --git a/requests_cache/backends/filesystem.py b/requests_cache/backends/filesystem.py
index a63f1d7..b5da0df 100644
--- a/requests_cache/backends/filesystem.py
+++ b/requests_cache/backends/filesystem.py
@@ -61,8 +61,10 @@ class FileCache(BaseCache):
def __init__(self, cache_name: AnyPath = 'http_cache', use_temp: bool = False, **kwargs):
super().__init__(**kwargs)
- self.responses = FileDict(cache_name, use_temp=use_temp, **kwargs)
- self.redirects = SQLiteDict(self.cache_dir / 'redirects.sqlite', 'redirects', **kwargs)
+ self.responses: FileDict = FileDict(cache_name, use_temp=use_temp, **kwargs)
+ self.redirects: SQLiteDict = SQLiteDict(
+ self.cache_dir / 'redirects.sqlite', 'redirects', **kwargs
+ )
@property
def cache_dir(self) -> Path: