Skip to content

Commit

Permalink
Add formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
CarrotManMatt committed Nov 7, 2024
1 parent 832510d commit 3dd46db
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 130 deletions.
71 changes: 34 additions & 37 deletions .github/workflows/check_build_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,21 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install mypy From Locked Dependencies
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads
--only-group type-check --frozen
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads --only-group
type-check --frozen

- name: Save Hashed Python Version
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads
--python ${{ matrix.python-version }} python -VV | sha256sum
| cut -d' ' -f1)" >> $GITHUB_ENV
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads --python
${{ matrix.python-version }} python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

- uses: actions/cache@v4
with:
path: ./.mypy_cache
key: mypy|${{ env.HASHED_PYTHON_VERSION }}

- name: Run mypy
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads
mypy .
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads mypy
.

pre-commit:
needs: uv-check
Expand All @@ -85,9 +84,8 @@ jobs:
run: uv sync --no-python-downloads --only-group pre-commit --frozen

- name: Save Hashed Python Version
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads
--python ${{ matrix.python-version }} python -VV | sha256sum
| cut -d' ' -f1)" >> $GITHUB_ENV
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads --python
${{ matrix.python-version }} python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

- uses: actions/cache@v4
with:
Expand All @@ -102,8 +100,8 @@ jobs:
>> $GITHUB_ENV

- name: Run pre-commit
run: uv run --no-sync --no-python-downloads pre-commit run --all-files
--hook-stage manual
run: uv run --no-sync --no-python-downloads pre-commit run --all-files --hook-stage
manual

pytest:
needs: uv-check
Expand All @@ -128,22 +126,20 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install pytest From Locked Dependencies
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads
--only-group test --frozen
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads --only-group
test --frozen

- name: Save Hashed Python Version
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads
--python ${{ matrix.python-version }} python -VV | sha256sum
| cut -d' ' -f1)" >> $GITHUB_ENV
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads --python
${{ matrix.python-version }} python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

- uses: actions/cache@v4
with:
path: ./.pytest_cache
key: pytest|${{ env.HASHED_PYTHON_VERSION }}

- name: Run pytest
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads
pytest
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads pytest

ruff:
needs: uv-check
Expand All @@ -168,22 +164,21 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Install ruff From Locked Dependencies
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads
--only-group lint --frozen
run: uv sync --python ${{ matrix.python-version }} --no-python-downloads --only-group
lint --frozen

- name: Save Hashed Python Version
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads
--python ${{ matrix.python-version }} python -VV | sha256sum
| cut -d' ' -f1)" >> $GITHUB_ENV
run: echo "HASHED_PYTHON_VERSION=$(uv run --no-sync --no-python-downloads --python
${{ matrix.python-version }} python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV

- uses: actions/cache@v4
with:
path: ./.ruff_cache
key: ruff|${{ env.HASHED_PYTHON_VERSION }}

- name: Run Ruff
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads
ruff check --output-format=github
run: uv run --python ${{ matrix.python-version }} --no-sync --no-python-downloads ruff
check --output-format=github

taplo-format:
runs-on: ubuntu-latest
Expand All @@ -197,9 +192,11 @@ jobs:
enable-cache: true
cache-dependency-glob: uv.lock

- name: Install Taplo From Locked Dependencies
run: uv sync --no-python-downloads --only-group lint-format --frozen

- name: Run Taplo Formatter
run: uvx taplo format . --check --option reorder_arrays=true --option
reorder_keys=true --option "indent_string= "
run: uv run taplo format . --check

taplo-lint:
runs-on: ubuntu-latest
Expand All @@ -213,8 +210,11 @@ jobs:
enable-cache: true
cache-dependency-glob: uv.lock

- name: Install Taplo From Locked Dependencies
run: uv sync --no-python-downloads --only-group lint-format --frozen

- name: Run Taplo Linter
run: uvx taplo lint . --default-schema-catalogs
run: uv run taplo lint . --default-schema-catalogs

yamlfmt:
runs-on: ubuntu-latest
Expand All @@ -231,10 +231,7 @@ jobs:
run: go install github.com/google/yamlfmt/cmd/yamlfmt@latest

- name: Run yamlfmt
run: yamlfmt . -lint -formatter indent=4 -formatter line_ending=lf
-formatter disallow_anchors=true -formatter max_line_length=75
-formatter trim_trailing_whitespace=true -formatter eof_newline=true
-formatter retain_line_breaks_single=true -formatter pad_line_comments=2
run: yamlfmt . -lint

build:
needs: [mypy, pre-commit, pytest, ruff, taplo-format, taplo-lint, yamlfmt]
Expand Down Expand Up @@ -338,11 +335,11 @@ jobs:
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository
}}' --notes ""
run: gh release create '${{ github.ref_name }}' --repo '${{ github.repository }}' --notes
""

- name: Add Signed Build Artifacts To GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: gh release upload '${{ github.ref_name }}' dist/** --repo
'${{ github.repository }}'
run: gh release upload '${{ github.ref_name }}' dist/** --repo '${{ github.repository
}}'
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ repos:
rev: v0.9.3
hooks:
- id: taplo-format
args: [--option, 'indent_string= ', --option, reorder_arrays=true,
--option, reorder_keys=true]

- id: taplo-lint
args: [--default-schema-catalogs]
Expand All @@ -80,7 +78,3 @@ repos:
rev: v0.14.0
hooks:
- id: yamlfmt
args: [-formatter, indent=4, -formatter, line_ending=lf, -formatter,
disallow_anchors=true, -formatter, max_line_length=75, -formatter,
trim_trailing_whitespace=true, -formatter, eof_newline=true, -formatter,
retain_line_breaks_single=true, -formatter, pad_line_comments=2]
6 changes: 6 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[formatting]
column_width = 95
indent_string = " "
reorder_arrays = true
reorder_inline_tables = true
reorder_keys = true
10 changes: 10 additions & 0 deletions .yamlfmt.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
line_ending: lf
gitignore_excludes: true
formatter:
indent: 4
retain_line_breaks_single: true
disallow_anchors: true
max_line_length: 95
trim_trailing_whitespace: true
eof_newline: true
pad_line_comments: 2
103 changes: 19 additions & 84 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ requires = ["hatch-docstring-description", "hatch-vcs", "hatchling"]

[dependency-groups]
dev = [
{ include-group = "lint" },
{ include-group = "lint-format" },
{ include-group = "pre-commit" },
{ include-group = "test" },
{ include-group = "type-check" },
]
lint = ["ruff>=0.4"]
lint-format = ["ruff>=0.4", "taplo"]
pre-commit = ["pre-commit"]
test = ["pytest"]
type-check = ["mypy>=1.10"]
Expand All @@ -33,8 +33,7 @@ classifiers = [
"Topic :: Software Development",
"Typing :: Typed",
]
description = "Typed decorators for classproperty and cached_classproperty."
dynamic = ["version"]
dynamic = ["description", "version"]
keywords = ["classmethod", "decorator", "property"]
maintainers = [{ name = "Matt Norton", email = "[email protected]" }]
name = "typed_classproperties"
Expand All @@ -48,6 +47,8 @@ Repository = "https://github.com/CarrotManMatt/typed_classproperties"
[tool.hatch.build]
only-packages = true

[tool.hatch.metadata.hooks.docstring-description]

[tool.hatch.version]
raw-options = { local_scheme = "no-local-version", version_scheme = "python-simplified-semver" }
source = "vcs"
Expand All @@ -73,11 +74,14 @@ warn_unused_ignores = true
python_files = "tests.py"

[tool.ruff]
indent-width = 4
line-length = 95

[tool.ruff.format]
docstring-code-format = true
indent-style = "space"
line-ending = "lf"
quote-style = "double"
skip-magic-trailing-comma = true

[tool.ruff.lint]
Expand All @@ -87,14 +91,17 @@ ignore = [
"C90",
"COM812",
"COM819",
"CPY",
"D206",
"D207",
"D208",
"D212",
"D300",
"E111",
"E114",
"E117",
"DJ",
"FA",
"FAST",
"INP001",
"ISC001",
"ISC002",
"N806",
"PD",
"PIE808",
"Q000",
"Q001",
Expand All @@ -106,76 +113,8 @@ ignore = [
"TD003",
"W191",
]
select = [
"A",
"ANN",
"ARG",
"ASYNC",
"B",
"BLE",
"C",
"COM",
"D",
"D204",
"D213",
"D400",
"D401",
"D404",
"DOC",
"DTZ",
"E",
"EM",
"ERA",
"EXE",
"F",
"FBT",
"FIX",
"FLY",
"FURB",
"G",
"I",
"ICN",
"INP",
"INT",
"ISC",
"LOG",
"N",
"PERF",
"PGH",
"PIE",
"PL",
"PT",
"PTH",
"PYI",
"Q",
"RET",
"RSE",
"RUF",
"S",
"SIM",
"SLF",
"SLOT",
"T",
"TCH",
"TD",
"TID",
"TRY",
"UP",
"W",
"YTT",
]
task-tags = [
"BUG",
"DONE",
"FIXME",
"HACK",
"IDEA",
"ISSUE",
"NOBUG",
"NOTE",
"REQ",
"TODO",
]
select = ["ALL", "D204", "D213", "D401"]
task-tags = ["BUG", "DONE", "FIXME", "HACK", "IDEA", "ISSUE", "NOBUG", "NOTE", "REQ", "TODO"]

[tool.ruff.lint.flake8-pytest-style]
fixture-parentheses = true
Expand All @@ -191,8 +130,6 @@ strict = true

[tool.ruff.lint.pep8-naming]
classmethod-decorators = [
"classproperties.cached_classproperty",
"classproperties.classproperty",
"typed_classproperties.cached_classproperty",
"typed_classproperties.classproperty",
]
Expand All @@ -215,8 +152,6 @@ max-doc-length = 95
[tool.ruff.lint.pydocstyle]
convention = "google"
property-decorators = [
"classproperties.cached_classproperty",
"classproperties.classproperty",
"typed_classproperties.cached_classproperty",
"typed_classproperties.classproperty",
]
Expand Down
Loading

0 comments on commit 3dd46db

Please sign in to comment.