cmake-format-precommit icon indicating copy to clipboard operation
cmake-format-precommit copied to clipboard

Fix environment adding pyyaml to install requirements

Open Kr4is opened this issue 3 years ago • 11 comments

This hook was failing due to a ModuleNotFoundError: No module named 'yaml'. I have updated the setup config to add pyyaml>=5.1, fixing that error.

Before:

imagen

After:

imagen

Kr4is avatar Mar 22 '21 08:03 Kr4is

yaml isn't a requirement unless you want to use yaml config (python or json config formats require no additional modules).

cheshirekow avatar Jun 13 '21 21:06 cheshirekow

First of all, sorry for the late reply, it has been a very busy month.

I see your point, but in my opinion the precommit hook should support the whole cmake format utility. That means support all formats witch the original tool supports, independent if you use python, json or yaml at your config. Thats also allow all people to use the extension only adding the hook without change theoir current configuration, if you use yaml for the configuration in your project, you can still using it, without need doin modifications.

I think that the pyyaml module is not a big overload, from my point of view is better having the full real utility instead of do not install a small module.

Finally, thank you for creating and maintaining this hook! I am currently using it in several projects and it helps me to keep these files in order and in a common format!

Kr4is avatar Jul 03 '21 12:07 Kr4is

For reference, I am currently using the repo of @Kr4is to be able to configure via yaml file

- repo: https://github.com/Kr4is/cmake-format-precommit
  rev: v0.6.14

m-kuhn avatar Oct 13 '21 09:10 m-kuhn

@m-kuhn Thats great!

Also i need to say that you can use the following in order to use the @cheshirekow repo with yaml configuration files:

-   repo: https://github.com/cheshirekow/cmake-format-precommit
    rev: v0.6.13
    hooks:
    -    id: cmake-format
         additional_dependencies: [pyyaml>=5.1]
    -    id: cmake-lint
         additional_dependencies: [pyyaml>=5.1]

greetings!

Kr4is avatar Oct 14 '21 15:10 Kr4is

Thanks for pointing that out. In this case I'll switch back with this trick 🙏

Would be nice to apply your proposed fix or have the precommit hook print this hint instead of the import error.

m-kuhn avatar Oct 14 '21 16:10 m-kuhn

Hi, @Kr4is thank you for this PR, I agree with @m-kuhn that it would be nice to see it merged or have the pre-commit hook print this hint instead of the import error. Just a marginal question, do I have to provide a particular option to the cmake-format pre-commit hook to specify the path of my yaml configuration file or it is able to detect it by itself?

Andreagit97 avatar Jun 11 '22 15:06 Andreagit97

Hello @Andreagit97 ,

As can be seen in the documentation of cmakelang we have two options. The first one is to specify with the -c parameter where is the configuration we want to use. The second is to use the predefined name to find it, in the case of configurations in yaml format the name should be the following: .cmake-format.yaml, being this file in the root of the repository.

I hope my answer has been helpful!

Best regards and thanks for the comment!

Kr4is avatar Jun 15 '22 07:06 Kr4is

Hello @Andreagit97 ,

As can be seen in the documentation of cmakelang we have two options. The first one is to specify with the -c parameter where is the configuration we want to use. The second is to use the predefined name to find it, in the case of configurations in yaml format the name should be the following: .cmake-format.yaml, being this file in the root of the repository.

I hope my answer has been helpful!

Yes, thank you very much!

Best regards and thanks for the comment!

Andreagit97 avatar Jun 15 '22 21:06 Andreagit97

@m-kuhn Thats great!

Also i need to say that you can use the following in order to use the @cheshirekow repo with yaml configuration files:

-   repo: https://github.com/cheshirekow/cmake-format-precommit
    rev: v0.6.13
    hooks:
    -    id: cmake-format
         additional_dependencies: [pyyaml>=5.1]
    -    id: cmake-lint
         additional_dependencies: [pyyaml>=5.1]

greetings!

thanks @Kr4is

brccabral avatar Nov 19 '23 05:11 brccabral

Could this be merged finally? Thx!

gegles avatar Feb 20 '24 18:02 gegles

Hello, why can this not be merged? What's the hold out?

gegles avatar Mar 08 '24 00:03 gegles