Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linting the template check #287

Merged
merged 11 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ jobs:
run: cookiecutter . --no-input --output-dir cookie-template

- name: Run pre-commit
run: pre-commit run --all-files --color always --verbose
working-directory: cookie-template
run: |-
git add .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐛-fix here ☝️ ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That and the working-directory. We were never actually linting the template before.

pre-commit run --all-files --color always --verbose
working-directory: cookie-template/python-template
21 changes: 17 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ repos:
- id: ruff
args:
- --config=pyproject.toml
exclude: "{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}"
exclude: |-
(?x)(
Comment on lines +8 to +9
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've changed to this syntax in the case that we need to ignore more than one thing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. Why are we excluding this all of a sudden? And why all over the shop?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look, it's the exact same excludes that we had before. It's just the format which has changed.

Unfortunately, @pre-commit isn't using an array for exclude, so you have to rely on this ugly expression https://pre-commit.com/#regular-expressions

{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}
)
- id: ruff-format
args:
- --config=pyproject.toml
Expand All @@ -17,7 +20,10 @@ repos:
rev: v0.23.1
hooks:
- id: toml-sort-fix
exclude: "{{cookiecutter.project_slug}}/pyproject.toml"
exclude: |-
(?x)(
{{cookiecutter.project_slug}}/pyproject.toml
)
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.8.0
hooks:
Expand All @@ -26,12 +32,19 @@ repos:
- --config-file=pyproject.toml
additional_dependencies:
- pytest
exclude: "{{cookiecutter.project_slug}}/(src/{{cookiecutter.package_name}}|tests)"
exclude: |-
(?x)(
{{cookiecutter.project_slug}}/src/{{cookiecutter.package_name}}|
{{cookiecutter.project_slug}}/tests
)
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.1.0
hooks:
- id: prettier
exclude: "{{cookiecutter.project_slug}}/.github/workflows/tests.yml"
exclude: |-
(?x)(
{{cookiecutter.project_slug}}/.github/workflows/tests.yml
)
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -649,4 +649,4 @@ what you want to do, use the GNU Lesser General Public License instead of this
License. But first, please read
&lt;<http://www.gnu.org/philosophy/why-not-lgpl.html>&gt;.

{%- endif -%}
{%- endif %}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to @dpshelio for helping me on this one!

7 changes: 2 additions & 5 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ paths.source = [

[tool.mypy]
explicit_package_bases = true
plugins = [
"numpy.typing.mypy_plugin",
]

[tool.pytest.ini_options]
addopts = """
Expand All @@ -74,7 +71,7 @@ testpaths = [
fix = true
force-exclude = true
ignore = [
"COM812", # trailing commas (ruff-format recommended)
"COM812", # trailing commas (ruff-format recommended)
"D203", # no-blank-line-before-class
"D212", # multi-line-summary-first-line
"D407", # removed dashes lines under sections
Expand All @@ -86,7 +83,7 @@ per-file-ignores = {"tests*" = [
"S101",
]}
select = [
"ALL"
"ALL",
]
target-version = "py{{cookiecutter.min_python_version | replace('.', '')}}"
isort.known-first-party = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
"""{{cookiecutter.package_name}} package."""
from ._version import __version__ # noqa: F401