Skip to content

Commit 6966bbb

Browse files
committed
more linter updates
1 parent 3d02136 commit 6966bbb

12 files changed

Lines changed: 32 additions & 76 deletions

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ jobs:
3131
--data author_name=Drew
3232
--data author_email=ao@aol.com
3333
--data project_license=BSD
34-
--data preferred_linter=black
35-
--data use_isort=false
34+
--data enforce_style=["black"]
3635
--data mypy_type_checking=basic
3736
--data create_example_module=no
3837
--data include_notebooks=no
@@ -45,8 +44,7 @@ jobs:
4544
--data author_name=Drew
4645
--data author_email=ao@aol.com
4746
--data project_license=BSD
48-
--data preferred_linter=black
49-
--data use_isort=false
47+
--data enforce_style=["black"]
5048
--data mypy_type_checking=basic
5149
--data create_example_module=yes
5250
--data include_notebooks=no
@@ -59,8 +57,7 @@ jobs:
5957
--data author_name=Drew
6058
--data author_email=ao@aol.com
6159
--data project_license=BSD
62-
--data preferred_linter=pylint
63-
--data use_isort=false
60+
--data enforce_style=["pylint"]
6461
--data mypy_type_checking=basic
6562
--data create_example_module=no
6663
--data include_notebooks=no
@@ -114,7 +111,7 @@ jobs:
114111
python -m pylint --recursive=y ./src/ --rcfile=./src/.pylintrc
115112
116113
- name: black checks
117-
if: ${{ contains(matrix.copier_config.extra_flags, 'preferred_linter=black') }}
114+
if: ${{ contains(matrix.copier_config.extra_flags, 'enforce_style=["black"]') }}
118115
uses: psf/black@stable
119116
with:
120117
src: "../test/${{ matrix.copier_config.foldername }}/src"

‎docs/practices/ci_precommit.rst‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ any linting issues that it could not resolve but should be fixed.
1919
For each pull request, our ``pre-commit.ci`` workflow will:
2020

2121
* Clear outputs from Jupyter notebooks
22-
* Sort imports using ``isort``
23-
* According to the preferred linter selected:
24-
* Format code using ``black`` (including notebooks)
25-
* Check compliance with ``pylint`` rules
22+
* Analyze the src code style and report code that doesn't adhere, using
23+
the options you selected for your tooling set:
24+
25+
* "ruff": checks for linting rules, sorts imports, auto-formats code
26+
* "pylint": checks for compliance with pylint rules
27+
* "black": auto-formats code (including notebooks)
28+
* "isort": Sort imports using ``isort``
2629

2730
.. note::
2831
* Only a small subset of hooks declared in the ``.pre-commit-config.yaml`` file

‎docs/source/update_project.rst‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ following command:
117117

118118
.. code-block:: bash
119119
120-
>> copier update --force --data preferred_linter="black"
120+
>> copier update --force --data include_benchmarks=true
121121
122122
The full list of questions can be found
123123
`here <https://github.com/lincc-frameworks/python-project-template/blob/main/copier.yml>`_.

python-project-template/.github/workflows/{% if preferred_linter != 'none' %}pre-commit-ci.yml{% endif %}.jinja renamed to python-project-template/.github/workflows/pre-commit-ci.yml.jinja

File renamed without changes.

‎python-project-template/.github/workflows/{% if mypy_type_checking != 'none' %}type-checking.yml{% endif %}.jinja‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
python-version: ['3.8', '3.9', '3.10']
21+
python-version: {{ python_versions }}
2222

2323
steps:
2424
- uses: actions/checkout@v3

‎python-project-template/.github/workflows/{% if preferred_linter != 'none' %}linting.yml{% endif %}.jinja‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎python-project-template/.pre-commit-config.yaml.jinja‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ repos:
4343
name: Validate pyproject.toml
4444
description: Verify that pyproject.toml adheres to the established schema.
4545

46-
{% if use_isort == true %}
46+
{%- if 'isort' in enforce_style %}
4747
# Automatically sort the imports used in .py files
4848
- repo: https://github.com/pycqa/isort
4949
rev: 5.12.0
@@ -52,9 +52,9 @@ repos:
5252
name: Run isort
5353
description: Sort and organize imports in .py and .pyi files.
5454
types_or: [python, pyi]
55-
{% endif %}
55+
{%- endif %}
5656

57-
{% if preferred_linter == 'pylint' %}
57+
{%- if 'pylint' in enforce_style %}
5858
# Analyze the src code style and report code that doesn't adhere.
5959
- repo: local
6060
hooks:
@@ -86,7 +86,8 @@ repos:
8686
"-sn", # Don't display the score
8787
"--rcfile=tests/.pylintrc",
8888
]
89-
{% elif preferred_linter == 'black' %}
89+
{%- endif %}
90+
{%- if 'black' in enforce_style %}
9091
# Analyze the code style and report code that doesn't adhere.
9192
- repo: https://github.com/psf/black
9293
rev: 23.7.0
@@ -99,7 +100,8 @@ repos:
99100
# pre-commit's default_language_version, see
100101
# https://pre-commit.com/#top_level-default_language_version
101102
language_version: python3.10
102-
{% elif preferred_linter == 'ruff' %}
103+
{%- endif %}
104+
{%- if 'ruff' in enforce_style %}
103105
- repo: https://github.com/astral-sh/ruff-pre-commit
104106
# Ruff version.
105107
rev: v0.1.3

‎python-project-template/README.md.jinja‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ development using the following commands:
4343
```
4444

4545
Notes:
46-
1) The single quotes around `'[dev]'` may not be required for your operating system.
47-
2) `pre-commit install` will initialize pre-commit for this local repository, so
46+
1. The single quotes around `'[dev]'` may not be required for your operating system.
47+
2. `pre-commit install` will initialize pre-commit for this local repository, so
4848
that a set of tests will be run prior to completing a local commit. For more
4949
information, see the Python Project Template documentation on
5050
[pre-commit](https://lincc-ppt.readthedocs.io/en/latest/practices/precommit.html)
5151
{%- if include_notebooks %}
52-
3) Install `pandoc` allows you to verify that automatic rendering of Jupyter notebooks
52+
3. Install `pandoc` allows you to verify that automatic rendering of Jupyter notebooks
5353
into documentation for ReadTheDocs works as expected. For more information, see
5454
the Python Project Template documentation on
5555
[Sphinx and Python Notebooks](https://lincc-ppt.readthedocs.io/en/latest/practices/sphinx.html#python-notebooks)

‎python-project-template/pyproject.toml.jinja‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ dev = [
3838
"sphinx-rtd-theme", # Used to render documentation
3939
"sphinx-autoapi", # Used to automatically generate api documentation
4040
{%- endif %}
41-
{%- if preferred_linter == 'pylint' %}
41+
{%- if 'pylint' in enforce_style %}
4242
"pylint", # Used for static linting of files
43-
{%- elif preferred_linter == 'black' %}
43+
{%- endif %}
44+
{%- if 'black' in enforce_style %}
4445
"black", # Used for static linting of files
45-
{%- elif preferred_linter == 'ruff' %}
46+
{%- endif %}
47+
{%- if 'ruff' in enforce_style %}
4648
"ruff", # Used for static linting of files
4749
{%- endif %}
4850
{%- if mypy_type_checking != 'none' %}
@@ -84,8 +86,6 @@ target-version = ["py38"]
8486
profile = "black"
8587
line_length = 110
8688

87-
{%- if preferred_linter == 'ruff' %}
88-
8989
[tool.ruff]
9090
line-length = 110
9191
target-version = "py38"
@@ -106,7 +106,6 @@ select = [
106106
# isort
107107
"I",
108108
]
109-
{%- endif %}
110109
{%- if mypy_type_checking != 'none' %}
111110
[tool.setuptools.package-data]
112111
{{package_name}} = ["py.typed"]

python-project-template/src/{% if preferred_linter == 'pylint' %}.pylintrc{% endif %} renamed to python-project-template/src/{% if 'pylint' in enforce_style %}.pylintrc{% endif %}

File renamed without changes.

0 commit comments

Comments
 (0)