django-cms / djangocms-admin-style

django CMS Admin Style is a Django Theme tailored to the needs of django CMS.
http://www.django-cms.org/
Other
422 stars 117 forks source link

Sync pre-commit checks with django-cms #515

Open marksweb opened 9 months ago

marksweb commented 9 months ago

I've made changes over the weekend to the pre-commit hooks in django-cms.

Ideally we'll have these consistent between projects. The main thing in the change is adopting the ruff linter and formatter.

In theory you should be able to just copy & paste the config from django-cms into these other projects;

https://github.com/django-cms/django-cms/blob/develop-4/.pre-commit-config.yml

The way ruff works is dictated by the pyproject.toml config which you can see here;

https://github.com/django-cms/django-cms/blob/develop-4/pyproject.toml

This project has one already, so this isn't as much a copy & paste job. The main thing is to have the same things in the select block.

Then in django-cms you'll see it uses extend-ignore and extend-exclude. So where projects like this on have exclude and ignore, we want to update these to the extend- versions.

Then you'll see a # TODO fix separately block. Create one of these that includes all the checks that currently fail. These can be fixed in smaller PRs.

To make sure you can run ruff, it's a python package. So in your virtual env run python -m pip install ruff

Also make sure you have pre-commit setup;

python -m pip install pre-commit
pre-commit install

Now any commits you make will get checked by the project's hooks. And if you add more, you just run the pre-commit install again.

Now you can run ruff using ruff check .

This will run the defined checks against the current directory. It's at this point you need to make judgements on if it's running on any directories that you could exclude because it's not part of the project. And then start adding to that # TODO list of rules.

Hopefully that's enough info to get started, but let me know if you've any questions. And of course, you can query things on slack as well. Maybe using the contributors channel for things realted to these changes.

raffaellasuardini commented 9 months ago

I'm going to work on this

raffaellasuardini commented 9 months ago

This issue is solved in this pull request