Skip to content

Commit

Permalink
Update from upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
collijk committed May 6, 2024
2 parents 275b55f + 7cf1313 commit e443f9f
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 115 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: "3.12"
- run: python -m pip install pre-commit
- run: pre-commit run --all-files

Expand All @@ -32,7 +32,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: "3.12"
- run: python -m pip install cookiecutter pytest pyyaml
- run: pytest tests/

Expand All @@ -43,7 +43,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: "3.12"
- run: python -m pip install cookiecutter poetry
- run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 1.6.21
- name: Generate project
Expand All @@ -65,3 +65,4 @@ jobs:
cd example-project
poetry install
poetry run pre-commit run -a
poetry run mkdocs build
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ packages. Best practices with all the modern bells and whistles included.
* [Poetry](https://python-poetry.org/docs/) for managing dependencies and packaging
* [pre-commit](https://pre-commit.com/) for running all the goodies listed below
* [mypy](https://flake8.pycqa.org/en/latest/) for static type checking
* [flake8](https://flake8.pycqa.org/en/latest/) (with multiple plugins) for linting (e.g. style and complexity checks, commented code, etc.)
* [black](https://black.readthedocs.io/en/stable/) for auto-formatting the code
* [isort](https://pycqa.github.io/isort/) for auto-sorting imports
* [autoflake](https://github.com/myint/autoflake) for auto-removing unused imports
* [ruff](https://beta.ruff.rs/docs/) for automatic formatting, linting and automatically fixing some linting errors

#### Automation

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inputs:
python-version:
required: false
description: 'Python version'
default: '3.11'
default: '3.12'
outputs: {}
runs:
using: 'composite'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: "3.12"

- name: Install dependencies
run: python -m pip install cruft poetry jello tabulate
Expand Down
11 changes: 9 additions & 2 deletions {{cookiecutter.project_slug}}/.github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python-poetry-env
with:
python-version: ${{ matrix.python-version }}
- run: poetry run pytest{% endraw %}
- run: poetry run pytest

docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/python-poetry-env
- run: poetry run mkdocs build{% endraw %}
32 changes: 10 additions & 22 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,26 @@ repos:
- id: mixed-line-ending
- repo: local
hooks:
- id: autoflake
name: autoflake
entry: poetry run autoflake -r -i --remove-all-unused-imports --remove-unused-variables
- id: ruff-format
name: ruff-format
entry: poetry run ruff format
require_serial: true
language: system
types: [ python ]
- id: isort
name: isort
entry: poetry run isort
language: system
types: [python]
- id: black
name: black
entry: poetry run black
language: system
types: [python]
- id: pyupgrade
name: pyupgrade
entry: poetry run pyupgrade --py37-plus
- id: ruff
name: ruff
# Add --fix, in case you want it to autofix when this hook runs
entry: poetry run ruff check --force-exclude
require_serial: true
language: system
types: [python]
types: [ python ]
- id: mypy
name: mypy
entry: poetry run mypy .
require_serial: true
language: system
types: [python]
pass_filenames: false
- id: flake8
name: flake8
entry: poetry run flake8
language: system
types: [python]
- id: kacl-verify
name: kacl-verify
entry: poetry run kacl-cli verify
Expand Down
4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pip install {{ cookiecutter.project_slug }}
* Clone this repository
* Requirements:
* [Poetry](https://python-poetry.org/)
* Python 3.9+
* Python 3.10+
* Create a virtual environment and install the dependencies

```sh
Expand Down Expand Up @@ -64,7 +64,7 @@ Find the draft release from the

### Pre-commit

Pre-commit hooks run all the auto-formatters (e.g. `black`, `isort`), linters (e.g. `mypy`, `flake8`), and other quality
Pre-commit hooks run all the auto-formatting (`ruff format`), linters (e.g. `ruff` and `mypy`), and other quality
checks to make sure the changeset is in good shape before a commit/push happens.

You can install the hooks with (runs for each commit):
Expand Down
2 changes: 0 additions & 2 deletions {{cookiecutter.project_slug}}/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ plugins:
options:
show_signature_annotations: true
show_submodules: true


extra_javascript:
- https://unpkg.com/[email protected]/dist/tablesort.min.js
- _javascript/tablesort.js
Expand Down
92 changes: 52 additions & 40 deletions {{cookiecutter.project_slug}}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ classifiers = [
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Typing :: Typed",
]
Expand All @@ -33,30 +35,18 @@ packages = [
python = ">=3.10, <4.0"
click = "*"

[tool.poetry.dev-dependencies]
autoflake = "*"
black = "*"
flake8 = "*"
flake8-bugbear = "*"
flake8-builtins = "*"
flake8-comprehensions = "*"
flake8-debugger = "*"
flake8-eradicate = "*"
flake8-logging-format = "*"
isort = "*"
mkdocstrings = {version = ">=0.18", extras = ["python"]}
[tool.poetry.group.dev.dependencies]
mkdocstrings = {version = ">=0.23", extras = ["python"]}
mkdocs-material = "*"
mkdocs-table-reader-plugin = "*"
mypy = "*"
pep8-naming = "*"
pre-commit = "*"
pymdown-extensions = "*"
pytest = "*"
pytest-github-actions-annotate-failures = "*"
pytest-cov = "*"
python-kacl = "*"
pyupgrade = "*"
tryceratops = "*"
ruff = ">=0.2.0"

[build-system]
requires = ["poetry-core>=1.0.0"]
Expand All @@ -65,13 +55,36 @@ build-backend = "poetry.core.masonry.api"
[project.scripts]
my-cli = "{{ cookiecutter.package_name }}.cli:main"

[tool.isort]
profile = "black"
src_paths = ["src", "tests"]
[tool.ruff]
target-version = "py310" # The lowest supported version

[tool.black]
target-version = ["py310", "py311", "py312"]
include = '\.pyi?$'
[tool.ruff.lint]
# By default, enable all the lint rules.
# Add to the ignore list below if you don't want some rules.
# If you need some ignores for certain modules, see tool.ruff.lint.per-file-ignores below.
# For individual ignore cases, prefer inline `# noqa`s within the code.
select = ["ALL"]
ignore = [
"ANN", # Type hints related, let mypy handle these.
"D", # Docstrings related, way too strict to our taste
]

[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"S101", # "Use of `assert` detected"
"ARG", # "Unused function argument". Fixtures are often unused.
"S105", # "Possible hardcoded password".
]

[tool.ruff.lint.mccabe]
max-complexity = 10

[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"classmethod",
"pydantic.validator",
"pydantic.root_validator",
]

[tool.pytest.ini_options]
addopts = """\
Expand All @@ -89,24 +102,23 @@ exclude_lines = [
]

[tool.mypy]
disallow_any_unimported = false
disallow_untyped_defs = true
no_implicit_optional = true
strict_equality = true
warn_unused_ignores = true
warn_redundant_casts = true
warn_return_any = false
check_untyped_defs = true
show_error_codes = true

# Uncomment the following lines and add packages to the "module" list to
# handle mypy errors when 3rd party packages are not typed.
# This is the global mypy configuration.
# Avoid changing this!
strict = true # See all the enabled flags `mypy --help | grep -A 10 'Strict mode'`
disallow_any_unimported = true

# If you need to ignore something for some specific module,
# add overrides for them. Avoid changing the global config!
# For example:
# [[tool.mypy.overrides]]
# module = []
# module = [
# "my_unpyted_dependency1.*",
# "my_unpyted_dependency2.*"
# ]
# ignore_missing_imports = true

[tool.tryceratops]
ignore=["TRY003"]

[tool.autoflake]
ignore-init-module-imports = true
# [[tool.mypy.overrides]]
# module = [
# "tests/my_thing/test_my_thing",
# ]
# disallow_untyped_defs = false
38 changes: 0 additions & 38 deletions {{cookiecutter.project_slug}}/setup.cfg

This file was deleted.

0 comments on commit e443f9f

Please sign in to comment.