Coder Social home page Coder Social logo

Comments (18)

ofek avatar ofek commented on August 27, 2024

The solution would be to run just the formatter first via -f

from hatch.

warsaw avatar warsaw commented on August 27, 2024

Hmm, running hatch fmt -f turns all my single quotes to double quotes!

from hatch.

ofek avatar ofek commented on August 27, 2024

You would have to add configuration for that, see the config file in this repo

from hatch.

warsaw avatar warsaw commented on August 27, 2024

Ah, so hatch fmt -f doesn't use the same defaults as hatch fmt?

from hatch.

ofek avatar ofek commented on August 27, 2024

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.

warsaw avatar warsaw commented on August 27, 2024

I see! Thanks. Let me continue to play around with it.

from hatch.

warsaw avatar warsaw commented on August 27, 2024

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.

ofek avatar ofek commented on August 27, 2024

I'm confused, why is it trying to move the import somewhere other than the top?

from hatch.

warsaw avatar warsaw commented on August 27, 2024

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.

ofek avatar ofek commented on August 27, 2024

Fixed?

from hatch.

warsaw avatar warsaw commented on August 27, 2024

Nope, even with ruff 0.4.3.

from hatch.

ofek avatar ofek commented on August 27, 2024

You provide a minimal reproducible example file and open up an issue over there?

from hatch.

warsaw avatar warsaw commented on August 27, 2024

So, you don't think it's a hatch fmt problem specifically?

from hatch.

ofek avatar ofek commented on August 27, 2024

If you can provide a very small file to reproduce we could test by just enabling that single offending rule.

from hatch.

warsaw avatar warsaw commented on August 27, 2024

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.

ofek avatar ofek commented on August 27, 2024

Disable Hatch static analysis config: https://hatch.pypa.io/latest/config/internal/static-analysis/#no-config

from hatch.

warsaw avatar warsaw commented on August 27, 2024

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.

ofek avatar ofek commented on August 27, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.