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

chore: Use uv and ruff for local package installation and linting/formatting #1211

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3f8f52e
Ignore any venv that starts with `.venv`
schloerke Mar 7, 2024
17be6b4
Use `uv` for package installation
schloerke Mar 7, 2024
8e52e57
first pass at requiring `uv` and `venv` within makefile
schloerke Mar 7, 2024
b96572e
Add `ruff.toml` config; Set up many rules to be inforced in near future
schloerke Mar 11, 2024
6ac3cb2
Suggest vs code extension for ruff and use it on save
schloerke Mar 11, 2024
e14730f
Use `FORCE` approach within Makefile. Update checks for `black`/`isor…
schloerke Mar 11, 2024
9c026c0
Update .pre-commit-hooks.yaml
schloerke Mar 11, 2024
cc29521
Remove some linters
schloerke Mar 11, 2024
017298f
Fix a star import
schloerke Mar 11, 2024
b58cb20
`make format`
schloerke Mar 11, 2024
ce4a701
Update pytest.yaml
schloerke Mar 11, 2024
34b86cc
Update .gitignore
schloerke Mar 11, 2024
e81cbab
Use activate approach
schloerke Mar 11, 2024
fd417d5
Clean up docs rules and add `install-ci` target
schloerke Mar 11, 2024
c78174e
Update Makefile
schloerke Mar 12, 2024
0f452fe
Move annotation test from playwright to pytest
schloerke Mar 12, 2024
7718da4
Update Makefile
schloerke Mar 12, 2024
b485ea3
Update setup.cfg
schloerke Mar 12, 2024
5c990c3
typo
schloerke Mar 12, 2024
6eb4d4c
Restore missing target
schloerke Mar 12, 2024
b3112a7
Use correct docs target to build site (not preview)
schloerke Mar 12, 2024
71fd2bc
Discard changes to __init__.py files
schloerke Mar 12, 2024
628a20d
Do not use isort on init files
schloerke Mar 12, 2024
a5c3b87
Code feedback
schloerke Mar 12, 2024
6f84637
Add comments about pre-commit hooks and how to disable them temporarily
schloerke Mar 12, 2024
3d616fb
chore(lints): Add many rules for `ruff` (#1213)
schloerke Mar 12, 2024
dc03c01
Merge branch 'main' into build_tools
schloerke Mar 15, 2024
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
7 changes: 1 addition & 6 deletions .github/py-shiny/setup/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,10 @@ runs:
# cache-dependency-path: |
# setup.cfg

- name: Upgrade pip
shell: bash
run: python -m pip install --upgrade pip

- name: Install dependencies
shell: bash
run: |
pip install https://github.com/rstudio/py-htmltools/tarball/main
make install-deps
make install-ci

- name: Install
shell: bash
Expand Down
22 changes: 3 additions & 19 deletions .github/workflows/build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,45 +22,29 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: python -m pip install --upgrade pip

- name: Install Quarto
uses: quarto-dev/quarto-actions/setup@v2
with:
version: 1.3.340

- name: Install dependencies
run: |
cd docs
make ../venv
make deps

- name: Run quartodoc
run: |
cd docs
make quartodoc

- name: Build site
run: |
cd docs
make site
make docs-site

- name: Upload site artifact
if: github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v1
with:
path: "docs/_site"


deploy:
if: github.ref == 'refs/heads/main'
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
Expand Down
16 changes: 2 additions & 14 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,11 @@ jobs:
run: |
make check-types

- name: Lint with flake8
- name: Lint with ruff
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make check-lint

- name: black
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make check-black

- name: isort
if: steps.install.outcome == 'success' && (success() || failure())
run: |
make check-isort

playwright-shiny:
runs-on: ${{ matrix.os }}
if: github.event_name != 'release'
Expand Down Expand Up @@ -211,9 +201,7 @@ jobs:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install https://github.com/rstudio/py-htmltools/tarball/main
make install-deps
make install-ci
make install
- name: "Build Package"
run: |
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ coverage.xml
*.cover
.hypothesis/
.pytest_cache/
.ruff_cache/


# Translations
*.mo
Expand Down Expand Up @@ -84,7 +86,7 @@ celerybeat-schedule
.env

# virtualenv
.venv
.venv*/
venv/
ENV/

Expand Down
13 changes: 9 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# For the rare case that you'd like to commit with no pre-commit hooks, you can use `--no-verify` in the commit call.
# ```
# git commit --no-verify -m "MSG"
# ```
repos:
- repo: https://github.com/psf/black
rev: "24.2.0"
- repo: https://github.com/astral-sh/ruff-pre-commit
schloerke marked this conversation as resolved.
Show resolved Hide resolved
rev: v0.3.2
hooks:
- id: black
language_version: python3
- id: ruff
args: [--fix]
- id: ruff-format
5 changes: 5 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"recommendations": [
"charliermarsh.ruff"
]
}
3 changes: 1 addition & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.tabSize": 4,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"isort.args": ["--profile", "black"],
"editor.rulers": [88],
"files.exclude": {
"**/__pycache__": true,
Expand Down
Loading
Loading