Skip to content

Commit

Permalink
ci: update cruft
Browse files Browse the repository at this point in the history
  • Loading branch information
sarakolding authored Oct 31, 2023
1 parent a03c5a2 commit 93a07b6
Show file tree
Hide file tree
Showing 14 changed files with 670 additions and 32 deletions.
1 change: 0 additions & 1 deletion .cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"*.github"
],
"_template": "https://github.com/MartinBernstorff/swift-python-cookiecutter",
"add_makefile": "y",
"author": "Martin Bernstorff",
"copyright_year": "2023",
"email": "[email protected]",
Expand Down
3 changes: 1 addition & 2 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/MartinBernstorff/swift-python-cookiecutter",
"commit": "ad7156663893ea72553b2b94f007603b9157de6e",
"commit": "d0e8eb6aa3d3b1f39ff40e12f392316e65363833",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -12,7 +12,6 @@
"github_user": "MartinBernstorff",
"version": "0.0.0",
"copyright_year": "2023",
"add_makefile": "y",
"license": "MIT",
"_copy_without_render": [
"*.github"
Expand Down
7 changes: 5 additions & 2 deletions .github/recommended_repo_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@
* Require status checks to pass before merging
* Require branches to be up to date before merging
* Status checks that are required:
* mypy (type hinting)
* static_type_checks (type hinting)
* pre-commit (formatting)
* pytest (tests)
* check_for_rej (check for residual cruft updates)
* Require conversation resolution before merging
* Require conversation resolution before merging

### Publishing to PyPI
If do not wish to pypi, you can just delete the `release.yml` file. If you do wish to publish, you need to setup trusted publishing [here](https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/).
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
🏎️ Get results locally by running `pre-commit run --all-files`
🕵️ Examine the results in the `Run pre-commit` section of this workflow `pre-commit`
We also strongly recommend setting up the `ruff` and `black` extensions to auto-format on save in your chosen editor.
We also recommend setting up the `ruff` and `black` extensions to auto-format on save in your chosen editor.
- name: Commit formatting
if: ${{ steps.pre_commit.outputs.pre_commit_failed == 1 && github.event_name == 'pull_request' }}
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/static_type_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,15 @@ jobs:
with:
message: |
✨ Looks like pyright failed ✨
If you want to fix this, we recommend doing it locally by either:
a) Enabling pyright in VSCode and going through the errors in the problems tab (VSCode settings > Python > Analysis: Type checking mode > "basic")
a) Enabling pyright in VSCode and going through the errors in the problems tab
`VSCode settings > Python > Analysis: Type checking mode > "basic"`
b) Debugging via the command line
1. Installing pyright, which is included in the dev dependencies: `pip install -e ".[dev]"`
2. Diagnosing the errors by running `pyright .`
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/static_type_checks.yml.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
diff a/.github/workflows/static_type_checks.yml b/.github/workflows/static_type_checks.yml (rejected hunks)
@@ -1,7 +1,7 @@
-# We do not include mypy as a pre-commit hook because pre-commit hooks
-# are installed in their own virtual environment, so mypy cannot
+# We do not include static_type_checks as a pre-commit hook because pre-commit hooks
+# are installed in their own virtual environment, so static_type_checks cannot
# use stubs from imports
-name: mypy
+name: static_type_checks

on:
pull_request:
@@ -10,46 +10,44 @@ on:
branches: [main]

jobs:
- mypy:
+ static_type_checks:
runs-on: ubuntu-latest
permissions:
pull-requests: write
concurrency:
group: "${{ github.workflow }} @ ${{ github.ref }}"
cancel-in-progress: true
+ strategy:
+ matrix:
+ os: [ubuntu-latest]
+ python-version: ["3.9"]
steps:
- - uses: actions/checkout@v2
+ - uses: actions/checkout@v3

- - name: Cache venv
+ - name: Cache tox
uses: actions/[email protected]
- id: cache_venv
+ id: cache_tox
with:
path: |
- .venv
- key: ${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
+ .tox
+ key: ${{ runner.os }}-${{ matrix.python-version }}-static-type-checks

- name: Set up Python
uses: actions/setup-python@v4
id: setup_python
- if: steps.cache_venv.outputs.cache-hit != 'true'
with:
- python-version: "3.9"
+ python-version: ${{ matrix.python-version}}

- name: Install dependencies
shell: bash
- if: steps.cache_venv.outputs.cache-hit != 'true'
run: |
- python -m venv .venv
- source .venv/bin/activate
- python -m pip install --upgrade pip
- pip install -e .[dev]
+ pip install invoke tox

- name: Run static type checker
id: pyright
continue-on-error: true
run: |
- source .venv/bin/activate
- if pyright .; then
+ if inv static-type-checks; then
echo "pyright check passed"
echo "pyright_failed=0" >> $GITHUB_OUTPUT
else
@@ -91,4 +94,4 @@ jobs:
id: fail_run
if: ${{steps.pyright.outputs.pyright_failed == 1}}
run: |
- pyright . # Rerunning pyright isn't optimal computationally, but typically takes no more than a couple of seconds, and this ensures that the errors are in the failing step
+ inv static-type-checks # Rerunning pyright isn't optimal computationally, but typically takes no more than a couple of seconds, and this ensures that the errors are in the failing step
18 changes: 18 additions & 0 deletions .gitignore.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff a/.gitignore b/.gitignore (rejected hunks)
@@ -1,5 +1,4 @@
# Python
-.mypy_cache/
/.python-version
/.pytype/
/dist/
@@ -7,6 +6,10 @@
/src/*.egg-info/
__pycache__/
.*venv*
+_build/
+.tox
+
+#

# VSCode
.vscode/
12 changes: 0 additions & 12 deletions Makefile

This file was deleted.

22 changes: 22 additions & 0 deletions README.md.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
diff a/README.md b/README.md (rejected hunks)
@@ -4,9 +4,8 @@

[![PyPI](https://img.shields.io/pypi/v/timeseriesflattener.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/timeseriesflattener)][pypi status]
-[![documentation](https://github.com/MartinBernstorff/timeseriesflattener/workflows/documentation/badge.svg)][documentation]
+[![documentation](https://github.com/MartinBernstorff/timeseriesflattener/actions/workflows/documentation.yml/badge.svg)][documentation]
[![Tests](https://github.com/MartinBernstorff/timeseriesflattener/actions/workflows/tests.yml/badge.svg)][tests]
-
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]

[pypi status]: https://pypi.org/project/timeseriesflattener/
@@ -29,6 +28,9 @@ You can install `timeseriesflattener` via [pip] from [PyPI]:
pip install timeseriesflattener
```

+[pip]: https://pip.pypa.io/en/stable/installing/
+[PyPI]: https://pypi.org/project/timeseriesflattener/
+
## Usage

TODO: Add minimal usage example
10 changes: 10 additions & 0 deletions docs/conf.py.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
diff a/docs/conf.py b/docs/conf.py (rejected hunks)
@@ -82,7 +82,7 @@ html_theme_options = {
<svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0 0 16 8c0-4.42-3.58-8-8-8z"></path>
</svg>
- """, # noqa: E501
+ """,
"class": "",
},
],
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ exclude = [
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".pytype",
Expand Down
160 changes: 160 additions & 0 deletions pyproject.toml.rej
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
diff a/pyproject.toml b/pyproject.toml (rejected hunks)
@@ -3,55 +3,57 @@ requires = ["setuptools>=61.0.0", "wheel", "setuptools_scm"]
build-backend = "setuptools.build_meta"

[project]
+
+
name = "timeseriesflattener"
version = "0.0.0"
authors = [
- {name = "Martin Bernstorff", email = "[email protected]"}
+ { name = "Martin Bernstorff", email = "[email protected]" },
]
description = "Timeseriesflattener"
classifiers = [
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
- "Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
- "Programming Language :: Python :: 3.10"
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.11",
]
requires-python = ">=3.9"
-dependencies = [
- "pydantic"
-]
-
+dependencies = ["pydantic"]
[project.license]
file = "LICENSE"
name = "MIT"
[project.optional-dependencies]
dev = [
- "cruft",
- "pyright",
- "pre-commit==2.20.0,<2.21.0",
- "ruff==0.0.254", # important that these match the pre-commit hooks
- "black[jupyter]==22.8.0", # important that these match the pre-commit hooks
- "pandas-stubs", # type stubs for pandas
- "invoke",
+ "cruft>=2.0.0",
+ "pyright==1.1.305",
+ "pyright-polite>=0.0.1",
+ "pre-commit>=2.20.0",
+ "ruff>=0.0.254",
+ "black[jupyter]>=22.8.0",
+ "pandas-stubs>=0.0.0", # type stubs for pandas
+ "invoke==2.1.1",
]
tests = [
- "pytest>=7.1.3,<7.3.0",
- "pytest-cov>=3.0.0,<3.1.0",
- "pytest-xdist>=3.0.0,<3.2.0",
- "pytest-sugar>=0.9.4,<0.10.0",
+ "pytest>=7.1.3",
+ "pytest-cov>=3.0.0",
+ "pytest-xdist>=3.0.0",
+ "pytest-sugar>=0.9.4",
+ "tox>=4.5.0",
]
docs = [
- "sphinx>=5.3.0,<5.4.0",
- "furo>=2022.12.7,<2022.12.8", # theme
- "sphinx-copybutton>=0.5.1,<0.5.2",
- "sphinxext-opengraph>=0.7.3,<0.7.4",
- "sphinx_design>=0.3.0,<0.3.1",
- "sphinx_togglebutton>=0.2.3,<0.4.0",
- "myst-nb>=0.6.0,<1.17.0", # for rendering notebooks
- "jupyter>=1.0.0,<1.1.0", # for tutorials
+ "sphinx>=5.3.0",
+ "furo>=2022.12.7", # theme
+ "sphinx-copybutton>=0.5.1",
+ "sphinxext-opengraph>=0.7.3",
+ "sphinx_design>=0.3.0",
+ "sphinx_togglebutton>=0.2.3",
+ "myst-nb>=0.6.0", # for rendering notebooks
+ "jupyter>=1.0.0", # for tutorials
]

+
[project.readme]
file = "README.md"
content-type = "text/markdown"
@@ -62,7 +64,8 @@ repository = "https://github.com/MartinBernstorff/timeseriesflattener"
documentation = "https://MartinBernstorff.github.io/timeseriesflattener/"

[tool.pyright]
-exclude = [".*venv*"]
+exclude = [".*venv*", ".tox"]
+pythonPlatform = "Darwin"

[tool.ruff]
# Enable pycodestyle (`E`) and Pyflakes (`F`) codes by default.
@@ -92,17 +95,9 @@ select = [
"RET",
"RUF",
"SIM",
- "W"
-]
-ignore = [
- "ANN101",
- "ANN401",
- "E402",
- "E501",
- "F401",
- "F841",
- "RET504"
+ "W",
]
+ignore = ["ANN101", "ANN401", "E402", "E501", "F401", "F841", "RET504"]
ignore-init-module-imports = true
# Allow autofix for all enabled rules (when `--fix`) is provided.
unfixable = ["ERA"]
@@ -148,12 +142,39 @@ max-complexity = 10

[tool.semantic_release]
branch = "main"
-version_variable = [
- "pyproject.toml:version"
-]
-upload_to_pypi = false
-upload_to_release = false
+version_toml = ["pyproject.toml:project.version"]
build_command = "python -m pip install build; python -m build"

+
[tool.setuptools]
include-package-data = true
+
+
+[tool.tox]
+legacy_tox_ini = """
+[tox]
+envlist = py{39,310}
+
+[testenv]
+description: run unit tests
+extras = tests
+use_develop = true
+commands =
+ pytest -n auto {posargs:test}
+
+[testenv:type]
+description: run type checks
+extras = tests, dev
+basepython = py39 # Setting these explicitly avoid recreating env if your shell is set to a different version
+use_develop = true
+commands =
+ pyright src/
+
+[testenv:docs]
+description: build docs
+extras = docs
+basepython = py39 # Setting these explicitly avoid recreating env if your shell is set to a different version
+use_develop = true
+commands =
+ sphinx-build -b html docs docs/_build/html
+"""
Loading

0 comments on commit 93a07b6

Please sign in to comment.