Skip to content

Commit

Permalink
ci: faster with uv (#466)
Browse files Browse the repository at this point in the history
* ci: faster with uv

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Update noxfile.py

* style: pre-commit fixes

* chore: make newer pylint happy

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
henryiii and pre-commit-ci[bot] authored Oct 3, 2024
1 parent 12dccba commit 4a33ac4
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 69 deletions.
32 changes: 0 additions & 32 deletions .github/matchers/pylint.json

This file was deleted.

25 changes: 12 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,17 @@ jobs:
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- uses: astral-sh/setup-uv@v3
- uses: pre-commit/action@v3.0.1
with:
extra_args: --all-files --hook-stage manual
- name: PyLint
run: |
echo "::add-matcher::$GITHUB_WORKSPACE/.github/matchers/pylint.json"
pipx run nox -s pylint
run: uvx nox -s pylint -- --output-format=github


checks:
name: Check ${{ matrix.os }} Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
matrix:
Expand All @@ -41,7 +40,6 @@ jobs:
- {os: macos-13, python-version: '3.9'}
- {os: windows-latest, python-version: '3.8'}
- {os: windows-latest, python-version: '3.11'}
name: Check ${{ matrix.os }} Python ${{ matrix.python-version }}

steps:
- uses: actions/checkout@v4
Expand All @@ -51,8 +49,10 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- uses: astral-sh/setup-uv@v3

- name: Install package
run: python -m pip install -e .[test]
run: uv pip install --system -e .[test]

- name: Pytest
if: runner.os == 'Linux'
Expand Down Expand Up @@ -82,17 +82,16 @@ jobs:
with:
python-version: "3.x"

- name: Install package
run: python -m pip install -e .[test]

- name: Install notebook requirements
run: python -m pip install nbconvert jupyter_client ipykernel
- uses: astral-sh/setup-uv@v3

- name: Install dot
run: sudo apt-get install graphviz

- name: Install pydot
run: python -m pip install pydot
- name: Install package
run: uv pip install --system -e .[test]

- name: Install notebook requirements
run: uv pip install --system nbconvert jupyter_client ipykernel pydot

- name: Run the notebooks inplace
run: jupyter nbconvert --execute --inplace notebooks/DecayLanguageDemo.ipynb notebooks/ExampleDecFileParsingWithLark.ipynb
11 changes: 1 addition & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ repos:
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
types_or: [python, pyi, jupyter]
- id: ruff-format
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.11.2
hooks:
- id: mypy
files: '^src/decaylanguage/(decay|dec|utils)/'
additional_dependencies: [attrs, particle, importlib_resources, numpy>=1.26]
additional_dependencies: [attrs, particle, importlib_resources, numpy]

- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
Expand All @@ -55,10 +53,3 @@ repos:
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal

- repo: https://github.com/hadialqattan/pycln
rev: "v2.4.0"
hooks:
- id: pycln
args: [--all]
stages: [manual]
12 changes: 7 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@

nox.options.sessions = ["lint", "pylint", "tests"]

PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]

nox.needs_version = ">=2024.4.15"
nox.options.default_venv_backend = "uv|virtualenv"


@nox.session
Expand All @@ -21,14 +24,14 @@ def pylint(session: nox.Session) -> None:
Run pylint.
"""

session.install("pylint~=2.15.0")
session.install("-e", ".[dev]")
session.install("pylint")
session.install("-e.[dev]")
session.run("pylint", "src", *session.posargs)


@nox.session(python=PYTHON_VERSIONS)
def tests(session):
session.install(".[test]")
session.install("-y.[test]")
session.run("pytest", *session.posargs)


Expand All @@ -38,7 +41,6 @@ def build(session):
Build an SDist and wheel.
"""

session.install("build", "twine")
session.install("build", "twine", "check-wheel-contents")
session.run("python", "-m", "build")
session.run("twine", "check", "--strict", "dist/*")
Expand Down
4 changes: 1 addition & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ messages_control.disable = [
"too-many-public-methods",
"too-many-return-statements",
"too-many-statements",
"too-many-positional-arguments",
"wrong-import-position",
"invalid-name",
"consider-using-f-string", # TODO
Expand All @@ -144,9 +145,6 @@ messages_control.disable = [
"unused-argument", # covered by Ruff
]

[tool.ruff]
src = ["src"]

[tool.ruff.lint]
extend-select = [
"B", # flake8-bugbear
Expand Down
12 changes: 6 additions & 6 deletions src/decaylanguage/dec/dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,13 +311,13 @@ def _load_grammar(
with data.basepath.joinpath(filename).open() as f1:
self._grammar = f1.read()

self._grammar_info = dict(
lark_file=filename,
parser=parser,
lexer=lexer,
edit_terminals=self._generate_edit_terminals_callback(),
self._grammar_info = {
"lark_file": filename,
"parser": parser,
"lexer": lexer,
"edit_terminals": self._generate_edit_terminals_callback(),
**options,
)
}

def _generate_edit_terminals_callback(self) -> Callable[[TerminalDef], None]:
"""
Expand Down

0 comments on commit 4a33ac4

Please sign in to comment.