Comments (18)
The solution would be to run just the formatter first via -f
from hatch.
Hmm, running hatch fmt -f
turns all my single quotes to double quotes!
from hatch.
You would have to add configuration for that, see the config file in this repo
from hatch.
Ah, so hatch fmt -f
doesn't use the same defaults as hatch fmt
?
from hatch.
No it does but what's happening is that the linter comes first followed by the formatter and you're encountering an error in the former so the only way is to run the other one separately. This is a known issue where everything is not yet cohesive which is why they have a plan to only have a single command, and also the reason I have implemented this as a single command in preparation for that future.
from hatch.
I see! Thanks. Let me continue to play around with it.
from hatch.
I still have to add the noqa: I001
to the from __future__ import annotations
line, but I'm going to chalk this up to ruff's problem, not hatch's.
https://gitlab.com/warsaw/public/-/blob/hatch-fmt/src/public/public.py#L3
from hatch.
I'm confused, why is it trying to move the import somewhere other than the top?
from hatch.
I'm confused, why is it trying to move the import somewhere other than the top?
Great question! I'm confused why it wants to do that too.
from hatch.
Fixed?
from hatch.
Nope, even with ruff 0.4.3.
from hatch.
You provide a minimal reproducible example file and open up an issue over there?
from hatch.
So, you don't think it's a hatch fmt
problem specifically?
from hatch.
If you can provide a very small file to reproduce we could test by just enabling that single offending rule.
from hatch.
I don't know if this is reproducible outside the repository, but the file triggering the problem is public.py.
Another way to reproduce it is:
$ git clone https://gitlab.com/warsaw/public.git
$ cd public
# Edit src/public/public.py to remove the noqa comment from the future import line
$ hatch fmt --check src
src/public/public.py:7:1: I001 [*] Import block is un-sorted or un-formatted
Found 1 error.
[*] 1 fixable with the `--fix` option.
$ hatch fmt src
src/public/public.py:11:1: F404 `from __future__` imports must occur at the beginning of the file
Found 2 errors (1 fixed, 1 remaining).
$ git diff
diff --git a/src/public/public.py b/src/public/public.py
index 96bd404..bbe8d7f 100644
--- a/src/public/public.py
+++ b/src/public/public.py
@@ -4,11 +4,12 @@
# and linter will be in conflict between I001 and F404 (which wants to move
# this import to below `import sys`. Ruff's unified linter and formatter
# will hopefully resolve this: https://github.com/astral-sh/ruff/issues/8232
-from __future__ import annotations # noqa: I001
-
import sys
-from typing import Any, TYPE_CHECKING, overload
+from typing import TYPE_CHECKING, Any, overload
+
+from __future__ import annotations
+
if TYPE_CHECKING:
from .types import ModuleAware
from hatch.
Disable Hatch static analysis config: https://hatch.pypa.io/latest/config/internal/static-analysis/#no-config
from hatch.
Sorry, are you saying that this is not a bug in hatch, or it is caused by the ruff lint/formatter problem? One thing that I think would help to debug further is to be able to print the commands hatch is running with higher verbosity in hatch fmt
, but I believe you're fixing that already.
from hatch.
I'm not precisely sure what caused the issue but I thought that you weren't extending when in fact you seem to be doing so. I wonder what happens when you try the persistent config approach.
from hatch.
Related Issues (20)
- Vscode's pytest integration and `hatch test` do not work well together HOT 2
- Hatch doesn't install on ARM64 Windows HOT 1
- Building variant wheels from same source code HOT 5
- Several tests related to Python distributions fail on Fedora Linux on non-x86_64 architectures in Hatch 1.12.0 HOT 3
- Option to not print `cmd` input lines when running an array of scripts
- project.readme content-tyoe does not support specifying markdown flavors HOT 1
- Pyproject.toml expected encoding seems inconsistent, bug with `hatch test --cover` and special characters HOT 2
- Hatch shell fails: `TypeError: str expected, not NoneType`
- Creating an "empty wheel" (e.g. for a meta package that only installs dependencies) requires weird workarounds HOT 2
- A virtual environment `installer` other than `pip` or `uv` silently falls back to `pip`
- env issue ModuleNotFoundError: No module named 'pip._vendor.cachecontrol.caches'
- run environment with specific python patch-release version HOT 1
- Is pinning dependencies in the `hatch-test` environments recommended? HOT 2
- Non-python binary dependency
- Hatch no longer installs on Windows ARM64 HOT 2
- PKG-INFO Missing Metadata HOT 6
- Recommended License configuration leaves license null in project meta data HOT 4
- Migration from setup.py to project.toml: comments in requirements.txt are included HOT 3
- What is the canonical way to specify the packages to distribute?
- Hatch 1.12.0 ruff defaults invalid for Ruff 0.6.2 (match upstream flake8-trio/flake8-async) HOT 1
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 hatch.