Comments (19)
Most of my repos use pre-commit.ci, which runs pre-commit autoupdate
once a week (can be set to monthly) and PRs the result if it changes.
from pycln.
This is tiangolo/typer#377 - as long as they don't bump the version too high when fixing it, it will get fixed here automatically.
This is a great reason to avoid putting upper caps on things - it didn't protect against this, but it might protect against a fix! This would not have been caught (minor release, rather than major, and in a dependency, not this package), so adding upper caps when you knot know there will be a breakage doesn't help. See https://iscinumpy.dev/post/bound-version-constraints/.
from pycln.
Yep, that's what I'm doing. I have not updated it in the Developer Guidelines yet (https://scikit-hep.org/developer/style#pycln), but I have updated the matching cookie cutter (https://github.com/scikit-hep/cookie/blob/12c4755988652134eeadf82b0b562d02fdcfd7e8/%7B%7Bcookiecutter.project_name%7D%7D/.pre-commit-config.yaml#L63-L69). I'm assuming it will be fixed quickly, but if not, I'll update the dev pages too. :/
from pycln.
This was fixed in typer 0.4.1, so as long as you aren't getting an old cached version in pre-commit, this should be working again! tiangolo/typer#380
from pycln.
I just released Typer 0.4.1
that should handle this.
from pycln.
pre-commit clean
?
Also, pre-commit autoupdate
is not a setting, it just updates all the repos when you run it.
from pycln.
Thanks for explaining this here @henryiii! Indeed, I've just discovered this was an issue with typer.
from pycln.
Also experienced this, glad to have found this ticket!
Should we just do e.g. poetry add typer
and/or poetry add click
to pin the versions used? Or is https://github.com/wntrblm/nox/pull/590/files a better solution?
from pycln.
If you are using a lock file, it should still have the old versions if you don’t poetry update. All deps are pinned in a lock file.
from pycln.
(cloud-app-BL_P3mH3-py3.9) (⎈ minikube:cloud)➜ cloud-app git:(mc/sift-backfill-data) ✗ poetry show click
name : click
version : 7.1.2
description : Composable command line interface toolkit
So I'm assuming I could either specify the version of click
as in https://github.com/wntrblm/nox/pull/590/files, or I could lock click
in my lockfile to 8.0.4
.
from pycln.
And yes, poetry add “click<8.1” —dev
is a short term solution to allow poetry update.
from pycln.
I’d generally not add development dependencies in a shared environment (like a poetry environment). There no reason you should require click <8.1 because you use an application that requires it. Pre-commit is one way to avoid that. Nox/tox is another.
from pycln.
I think I follow what you're saying @henryiii - I ended up just locking the click
dependency via the pre-commit
config file:
- repo: https://github.com/hadialqattan/pycln
rev: v1.1.0 # Possible releases: https://github.com/hadialqattan/pycln/releases
hooks:
- id: pycln
args: [--config=pyproject.toml]
# TODO: When pycln resolves the issue
# with click (to be precise, when the typer
# dep fixes their issue with click), we should remove this
additional_dependencies: [ "click==8.0.4" ]
stages: [commit]
from pycln.
Yup. We can close this for now, I think 1. Thank you all!
Footnotes
-
Maybe pinning this issue could help people that faced this issue (and avoid extra tickets), but I'll leave it to the maintainers ;) ↩
from pycln.
@DiddiLeija how'd you do that cute footnote?!
from pycln.
Do y'all set pre-commit autoupdate
in your projects out of curiosity?
from pycln.
@DiddiLeija how'd you do that cute footnote?! 😅
https://github.blog/changelog/2021-09-30-footnotes-now-supported-in-markdown-fields/ :)
from pycln.
This was fixed in typer 0.4.1, so as long as you aren't getting an old cached version in pre-commit, this should be working again! tiangolo/typer#380
I cleared my pre-commit repo caches AFAIUI but still hitting the error:
(cloud-app-BL_P3mH3-py3.9) (⎈ minikube:cloud)➜ cloud-app git:(mc/update-precommit-and-run-all-files) ✗ pre-commit gc
9 repo(s) removed.
(cloud-app-BL_P3mH3-py3.9) (⎈ minikube:cloud)➜ cloud-app git:(mc/update-precommit-and-run-all-files) ✗ pre-commit autoupdate
Updating https://github.com/alessandrojcm/commitlint-pre-commit-hook ... already up to date.
Updating https://github.com/pre-commit/pre-commit-hooks ... already up to date.
Updating https://github.com/psf/black ... already up to date.
Updating https://github.com/pycqa/isort ... already up to date.
Updating https://github.com/hadialqattan/pycln ... already up to date.
Updating https://github.com/pre-commit/mirrors-prettier ... already up to date.
(cloud-app-BL_P3mH3-py3.9) (⎈ minikube:cloud)➜ cloud-app git:(mc/update-precommit-and-run-all-files) ✗ pre-commit run --all-files
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check for case conflicts.................................................Passed
black....................................................................Passed
isort....................................................................Passed
pycln....................................................................Failed
- hook id: pycln
- exit code: 1
Traceback (most recent call last):
File "/Users/mattysoup/.cache/pre-commit/repo1607zjh3/py_env-python3/bin/pycln", line 5, in <module>
from pycln.cli import app
File "/Users/mattysoup/.cache/pre-commit/repo1607zjh3/py_env-python3/lib/python3.9/site-packages/pycln/__init__.py", line 7, in <module>
import typer
File "/Users/mattysoup/.cache/pre-commit/repo1607zjh3/py_env-python3/lib/python3.9/site-packages/typer/__init__.py", line 12, in <module>
from click.termui import get_terminal_size as get_terminal_size
ImportError: cannot import name 'get_terminal_size' from 'click.termui' (/Users/mattysoup/.cache/pre-commit/repo1607zjh3/py_env-python3/lib/python3.9/site-packages/click/termui.py)
I just removed the pinned click
version from the .pre-commit-config.yaml
section for pycln
:
commit ab702250fe096bbda57484f4c9f43ddd1a2135f6 (HEAD -> mc/update-precommit-and-run-all-files)
Author: Matt Campbell <[email protected]>
Date: Thu Mar 31 09:37:04 2022 -0400
refactor(project): Remove pinned typer dep in pycln pre-commit
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c3ca2cb..b187b25 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -31,10 +31,6 @@ repos:
hooks:
- id: pycln
args: [ --config=pyproject.toml ]
- # TODO: When pycln resolves the issue
- # with click (to be precise, when the typer
- # dep fixes their issue with click), we should remove this
- additional_dependencies: [ "click<8.1" ]
stages: [ commit ]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.6.1 # Use the sha or tag you want to point at
from pycln.
pre-commit clean
?Also,
pre-commit autoupdate
is not a setting, it just updates all the repos when you run it.
You are a saint and a scholar!
from pycln.
Related Issues (20)
- (📚) Add a pronunciation guide to the readme HOT 4
- [BUG] Crash when encountering unknown toml HOT 8
- [FEATURE] pycln doesn't clean __init__.py files that lack __all__ dunder. HOT 2
- [FEATURE] Add scope analiythis
- [BUG] cleaned imports used in generics and wrapped in string HOT 7
- [BUG] fails removing unused import when in a tuple HOT 2
- [FEATURE] Release on conda-forge HOT 4
- Release new version with different upper limit for typer package HOT 3
- [BUG] `UnexpandableImportStar` without `expand-stars` or `expand_stars=true` HOT 3
- [FEATURE] Remove unused explicit imports from modules that (may) have side-effects
- [BUG] References in TypeAlias are not recognized which act as a str HOT 1
- [BUG] inlined with ':' for linters and type checkers HOT 3
- AttributeError: 'str' object has no attribute 'value' HOT 6
- [BUG] Module not found when package installed in editable mode from path HOT 1
- Pathspec dependency is incompatible with djlint HOT 5
- [BUG] Pycln does not preserve the original line-break format (CRLF/LF)
- [BUG] Imports removed from class scopes HOT 1
- [FEATURE] Do not remove explicitly re-exported imports even if unused
- [BUG] `pycln --all` removes an implicit import from a subpackage HOT 1
- [BUG] Imports used in deferred annotations unexpectedly cleaned HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycln.