Skip to content

Conversation

@mikita-sakalouski
Copy link

@mikita-sakalouski mikita-sakalouski commented Oct 1, 2024

Description

This PR adds a new pre-commit hook for Hatch. The hook ensures that Hatch commands are run as part of the pre-commit checks, helping to maintain consistency and quality in the project.

Example

repos:
-   repo: https://github.com/pypa/hatch #local
    rev: hatch-v1.13.0
    hooks:
    -   id : hatch
        name: hatch-config
        always_run: true
        args: [config, set, dirs.env.virtual, ".venv"]
    -   id: hatch-requirements-env-only
        name: hatch-requirements-env-only
        always_run: true
    -   id: hatch-requirements-all
        name: hatch-requirements-all
        always_run: true
    -   id: hatch-requirements-project-only
        name: hatch-requirements-project-only
        always_run: true
    -   id: hatch
        name: hatch-fmt
        always_run: true
        args: [fmt]

Output

> pre-commit run hatch-requirements-env-only
hatch-requirements-env-only..............................................Failed
- hook id: hatch-requirements-env-only
- duration: 0.18s
- files were modified by this hook
> git add requirements.txt 
> pre-commit run hatch-requirements-env-only --verbose
hatch-requirements-env-only..............................................Passed
- hook id: hatch-requirements-env-only
- duration: 0.15s
> pre-commit run hatch-requirements-all --verbose     
hatch-requirements-all...................................................Failed
- hook id: hatch-requirements-all
- duration: 0.12s
- files were modified by this hook
> git add requirements.txt                            
> pre-commit run hatch-requirements-all --verbose
hatch-requirements-all...................................................Passed
- hook id: hatch-requirements-all
- duration: 0.13s
> pre-commit run hatch-requirements-project-only      
hatch-requirements-project-only..........................................Failed
- hook id: hatch-requirements-project-only
- files were modified by this hook
> git add requirements.txt                       
> pre-commit run hatch-requirements-project-only
hatch-requirements-project-only..........................................Passed
> pre-commit run hatch                           
hatch-config.............................................................Passed
hatch-fmt................................................................Passed

Related issue

#1223

@mikita-sakalouski
Copy link
Author

@ofek Can you please have a look ?

@ofek
Copy link
Contributor

ofek commented Oct 2, 2024

I will soon

@mikita-sakalouski
Copy link
Author

@ofek Do I need to adjust anything? Not sure why tests are failing

@mikita-sakalouski
Copy link
Author

@ofek Please have a look)

@mikita-sakalouski
Copy link
Author

@ofek Can you run GitHub actions for this ?

@cjames23
Copy link
Member

Taking a look at this, I am not sure that running something like hatch dep show requirements is all that useful as a pre-commit hook. I would prefer that if add pre-commit hooks for hatch that it is focused on hatch fmt and hatch test for now and eventually when we add a command for type checking then to have that included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants