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

Ruff #23

Merged
merged 12 commits into from
Apr 17, 2024
Merged

Ruff #23

Show file tree
Hide file tree
Changes from 1 commit
Commits
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
31 changes: 0 additions & 31 deletions .flake8

This file was deleted.

90 changes: 4 additions & 86 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ on:
- main
- release**
jobs:
black:
name: black
ruff:
name: ruff
runs-on: ubuntu-latest
steps:
- name: Clone repo
Expand All @@ -19,96 +19,14 @@ jobs:
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Cache dependencies
uses: actions/[email protected]
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }}
- name: Install pip dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install -r requirements/style.txt
pip cache purge
- name: List pip dependencies
run: pip list
- name: Run black checks
run: black . --check --diff
flake8:
name: flake8
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/[email protected]
- name: Set up python
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Cache dependencies
uses: actions/[email protected]
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }}
- name: Install pip dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install -r requirements/style.txt
pip cache purge
- name: List pip dependencies
run: pip list
- name: Run flake8 checks
run: flake8
isort:
name: isort
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/[email protected]
- name: Set up python
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Cache dependencies
uses: actions/[email protected]
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }}
- name: Install pip dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install -r requirements/style.txt
pip cache purge
- name: List pip dependencies
run: pip list
- name: Run isort checks
run: isort . --check --diff
pyupgrade:
name: pyupgrade
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/[email protected]
- name: Set up python
uses: actions/[email protected]
with:
python-version: '3.11'
- name: Cache dependencies
uses: actions/[email protected]
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ env.pythonLocation }}-${{ hashFiles('requirements/style.txt') }}
- name: Install pip dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: |
pip install -r requirements/style.txt
pip cache purge
- name: List pip dependencies
run: pip list
- name: Run pyupgrade checks
run: pyupgrade --py39-plus
- name: Run ruff checks
run: ruff format --check -v
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}
cancel-in-progress: true
58 changes: 43 additions & 15 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ dynamic = ["version"]

[project.optional-dependencies]
style = [
"black[jupyter]>=21.8",
"flake8>=3.8",
"isort[colors]>=5.8",
"pyupgrade>=2.8",
"ruff>=0.3.0"
]
tests = [
"pytest>=7.3",
Expand All @@ -56,11 +53,6 @@ all = [
[project.urls]
Homepage = "https://github.com/isaaccorley/torchseg"

[tool.black]
target-version = ["py39", "py310"]
color = true
skip_magic_trailing_comma = true

[tool.coverage.report]
# Ignore warnings for overloads
# https://github.com/nedbat/coveragepy/issues/970#issuecomment-612602180
Expand All @@ -69,12 +61,6 @@ exclude_lines = [
"@overload",
]

[tool.isort]
profile = "black"
known_first_party = ["tests", "torchseg", "train"]
skip_gitignore = true
color_output = true

[tool.pytest.ini_options]
norecursedirs = [
".ipynb_checkpoints",
Expand All @@ -95,3 +81,45 @@ torchseg = ["py.typed"]

[tool.setuptools.packages.find]
include = ["torchseg*"]

[tool.ruff]
exclude = [
adamjstewart marked this conversation as resolved.
Show resolved Hide resolved
# Extra files
"data/",
"images/",
"logo/",
"logs/",
"output/",

# Docs
"docs/src/",

# Spack
".spack-env/",
isaaccorley marked this conversation as resolved.
Show resolved Hide resolved

# Python
"build/",
"dist/",
".cache/",
".mypy_cache/",
".pytest_cache/",
"__pycache__/",
"*.egg-info/",

# Git
".git/",
".github/",
isaaccorley marked this conversation as resolved.
Show resolved Hide resolved
]

line-length = 88
indent-width = 4
isaaccorley marked this conversation as resolved.
Show resolved Hide resolved
target-version = "py311"
isaaccorley marked this conversation as resolved.
Show resolved Hide resolved

[tool.ruff.format]
skip-magic-trailing-comma = true

[tool.ruff.lint]
ignore = ["E203"]
adamjstewart marked this conversation as resolved.
Show resolved Hide resolved

[tool.ruff.lint.isort]
known-first-party = ["tests", "torchseg"]
isaaccorley marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 1 addition & 4 deletions requirements/style.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
# style
black[jupyter]==24.3.0
flake8==7.0.0
isort[colors]==5.13.2
pyupgrade==3.15.2
ruff==0.3.5
Loading