Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pre-commit hook is incompatible with requests_cache==1.0 #514

Closed
eremeevfd opened this issue Mar 9, 2023 · 1 comment · Fixed by #518
Closed

Pre-commit hook is incompatible with requests_cache==1.0 #514

eremeevfd opened this issue Mar 9, 2023 · 1 comment · Fixed by #518
Labels
bug Something isn't working

Comments

@eremeevfd
Copy link

eremeevfd commented Mar 9, 2023

Expected behavior

Pre-commit hook works without exception

Current behavior


Traceback (most recent call last):
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/bin/nitpick", line 8, in <module>
    sys.exit(nitpick_cli())
             ^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/nitpick/cli.py", line 103, in fix
    common_fix_or_check(context, verbose, files, False)
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/nitpick/cli.py", line 82, in common_fix_or_check
    for fuss in nit.run(*files, autofix=not check_only):
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/nitpick/core.py", line 63, in run
    yield from chain(
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/nitpick/project.py", line 181, in merge_styles
    from nitpick.style import StyleManager
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/nitpick/style/__init__.py", line 2, in <module>
    from nitpick.style.cache import parse_cache_option
  File "/Users/f.eremeev/.cache/pre-commit/repo3x10obpc/py_env-python3/lib/python3.11/site-packages/nitpick/style/cache.py", line 8, in <module>
    from requests_cache.cache_control import DO_NOT_CACHE, NEVER_EXPIRE
ModuleNotFoundError: No module named 'requests_cache.cache_control'

Steps to reproduce

  1. install nitpick (or upgrade requests_cache to 1.0)
  2. set cache = never in pyproject.toml for nitpick
  3. run pre-commit with nitpick hook
  4. catch exception

Possible Solution

pin requests_cache to <1.0
or update import in this file:

nitpick/style/cache.py
from requests_cache.cache_control import DO_NOT_CACHE, NEVER_EXPIRE

change to:

from requests_cache.policy.expiration import DO_NOT_CACHE, NEVER_EXPIRE

Your environment

  • nitpick version used: 0.32

  • Python version: 3.11

  • Operating System and version: Mac OS Ventura 13.2.1 (22D68)

  • Run the following commands and paste the output:

    which python3
    python3 -V
    pip freeze
    cat $(which flake8)

Output:

/Users/f.eremeev/saas/saas_core_v2/.venv/bin/python3
Python 3.11.2
aiohttp==3.8.4
aiosignal==1.3.1
anyio==3.6.2
appdirs==1.4.4
asgiref==3.6.0
astor==0.8.1
async-timeout==4.0.2
attrs==21.4.0
autorepr==0.3.0
backoff==2.2.1
bandit==1.7.4
black==23.1.0
CacheControl==0.12.11
cached-property==1.5.2
cachetools==5.3.0
casbin==1.17.6
casbin-django-orm-adapter==1.0.2
cattrs==22.2.0
certifi==2022.12.7
cffi==1.15.1
chardet==4.0.0
charset-normalizer==3.0.1
click==8.1.3
cognitive-complexity==1.3.0
ConfigUpdater==3.1.1
coverage==7.2.1
cryptography==38.0.4
defusedxml==0.7.1
Deprecated==1.2.13
dictdiffer==0.9.0
Django==4.1.7
django-countries==7.5.1
django-extensions==3.2.1
django-health-check==3.17.0
django-object-actions==4.1.0
django-otp==1.1.4
django-pglocks==1.0.4
django-prometheus==2.2.0
django-rq==2.7.0
djangorestframework==3.14.0
djangorestframework-csv==2.1.1
dlint==0.14.0
dnspython==2.3.0
dpath==2.1.4
drf-spectacular==0.26.0
email-validator==1.3.1
eradicate==2.2.0
execnet==1.9.0
Faker==17.6.0
firebase-admin==6.1.0
flake8==5.0.4
flake8-annotations-complexity==0.0.7
flake8-bandit==4.1.1
flake8-black==0.3.6
flake8-bugbear==23.2.13
flake8-cognitive-complexity==0.1.0
flake8-comprehensions==3.10.1
flake8-eradicate==1.4.0
flake8-isort==6.0.0
flake8-length==0.3.1
flake8-mutable==1.2.0
flake8-pie==0.16.0
flake8-plugin-utils==1.3.2
flake8-print==5.0.0
flake8-pytest==1.4
flake8-quotes==3.3.2
flake8-return==1.2.0
flake8-simplify==0.19.3
flake8-string-format==0.3.0
flake8-todos==0.2.1
flake8-variables-names==0.0.5
flatten-dict==0.4.2
freezegun==1.2.2
frozenlist==1.3.3
furl==2.1.3
future==0.18.3
gcloud-aio-auth==4.1.5
gcloud-aio-pubsub==5.2.0
gitdb==4.0.10
GitPython==3.1.31
google-api-core==2.11.0
google-api-python-client==2.80.0
google-auth==2.16.2
google-auth-httplib2==0.1.0
google-cloud-core==2.3.2
google-cloud-firestore==2.10.0
google-cloud-monitoring==2.14.1
google-cloud-pubsub==2.15.0
google-cloud-storage==2.7.0
google-cloud-trace==1.10.0
google-crc32c==1.5.0
google-resumable-media==2.4.1
googleapis-common-protos==1.58.0
grpc-google-iam-v1==0.12.6
grpcio==1.51.3
grpcio-status==1.51.3
gunicorn==20.1.0
h11==0.14.0
hautai-google-trace-logging==1.1.5
hautai-vault==2.5.4
httpcore==0.16.3
httplib2==0.21.0
httptools==0.5.0
httpx==0.23.3
hvac==1.0.2
identify==2.5.18
idna==3.4
inflection==0.5.1
iniconfig==2.0.0
isort==5.12.0
jira==3.4.1
jmespath==1.0.1
jsonref==1.1.0
jsonschema==4.17.3
loguru==0.6.0
marshmallow==3.19.0
marshmallow-polyfield==5.11
mccabe==0.7.0
more-itertools==9.1.0
msgpack==1.0.4
multidict==6.0.4
mypy==1.0.1
mypy-extensions==1.0.0
netaddr==0.8.0
nitpick==0.32.0
oauthlib==3.2.2
opencensus==0.11.1
opencensus-context==0.1.3
opencensus-ext-django==0.8.0
opencensus-ext-ocagent==0.7.1
opencensus-proto==0.1.0
opentelemetry-api==1.15.0
opentelemetry-exporter-gcp-monitoring==1.4.0a0
opentelemetry-exporter-gcp-trace==1.4.0
opentelemetry-instrumentation==0.36b0
opentelemetry-instrumentation-django==0.36b0
opentelemetry-instrumentation-httpx==0.36b0
opentelemetry-instrumentation-wsgi==0.36b0
opentelemetry-propagator-gcp==1.4.0
opentelemetry-sdk==1.15.0
opentelemetry-semantic-conventions==0.36b0
opentelemetry-util-http==0.36b0
orderedmultidict==1.0.1
packaging==23.0
pathspec==0.11.0
pbr==5.11.1
pep8-naming==0.13.3
Pillow==9.4.0
pillow-avif-plugin==1.3.1
platformdirs==3.1.0
pluggy==1.0.0
prometheus-client==0.16.0
proto-plus==1.22.2
protobuf==4.22.0
psutil==5.9.4
psycopg2-binary==2.9.5
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycodestyle==2.9.1
pycparser==2.21
pydantic==1.10.5
pyflakes==2.5.0
pyhcl==0.4.4
PyJWT==2.6.0
pyparsing==3.0.9
pypng==0.20220715.0
pyrsistent==0.19.3
pytest==7.2.2
pytest-cov==4.0.0
pytest-django==4.5.2
pytest-env==0.8.1
pytest-mock==3.10.0
pytest-xdist==3.2.0
python-dateutil==2.8.2
python-dotenv==1.0.0
python-slugify==8.0.1
python3-openid==3.2.0
pytz==2022.7.1
PyYAML==6.0
qrcode==7.4.2
redis==4.5.1
requests==2.28.2
requests-cache==1.0.0
requests-oauthlib==1.3.1
requests-toolbelt==0.10.1
rfc3986==1.5.0
rq==1.13.0
rsa==4.9
ruamel.yaml==0.17.21
ruff==0.0.254
sentry-sdk==1.16.0
setproctitle==1.3.2
simpleeval==0.9.13
six==1.16.0
smmap==5.0.0
sniffio==1.3.0
social-auth-app-django==5.0.0
social-auth-core==4.3.0
sortedcontainers==2.4.0
sqlparse==0.4.3
stevedore==5.0.0
StrEnum==0.4.9
stripe==5.2.0
text-unidecode==1.3
toml==0.10.2
tomli==2.0.1
tomlkit==0.11.6
types-cachetools==5.2.1
types-docutils==0.19.1.1
types-mock==5.0.0.0
types-protobuf==4.21.0.2
types-python-dateutil==2.8.19.5
types-PyYAML==6.0.12.2
types-redis==4.4.0.0
types-requests==2.28.11.7
types-setuptools==65.7.0.1
types-urllib3==1.26.25.4
typing_extensions==4.5.0
unicodecsv==0.14.1
uritemplate==4.1.1
url-normalize==1.4.3
urllib3==1.26.14
uvicorn==0.20.0
uvloop==0.17.0
watchfiles==0.18.1
websockets==10.4
wrapt==1.14.1
yarl==1.8.2
#!/Users/f.eremeev/saas/saas_core_v2/.venv/bin/python
# -*- coding: utf-8 -*-
import re
import sys
from flake8.main.cli import main
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

For more information, see the CONTRIBUTING guide.

@eremeevfd eremeevfd added the bug Something isn't working label Mar 9, 2023
@andreoliwa andreoliwa moved this from Triage to Upvoted / Requests in Nitpick Roadmap Mar 13, 2023
@andreoliwa andreoliwa moved this from Upvoted / Requests to In progress in Nitpick Roadmap Mar 21, 2023
@andreoliwa andreoliwa linked a pull request Mar 24, 2023 that will close this issue
1 task
@github-project-automation github-project-automation bot moved this from In progress to Done in Nitpick Roadmap Mar 24, 2023
@andreoliwa
Copy link
Owner

Fixed by #518.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
2 participants