Skip to content

Commit

Permalink
Use ruff format instead of black
Browse files Browse the repository at this point in the history
  • Loading branch information
Parnassius committed Nov 28, 2024
1 parent 2bb9192 commit 4f32a00
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 129 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
python-version: "3.9"
cache: "pip"
cache-dependency-path: "pyproject.toml"
- name: Check formatting with black
run: hatch run black --check
- name: Check formatting
run: hatch run ruff-format --check
- name: Check docstrings with darglint
run: hatch run darglint
- name: Type check with mypy
Expand Down Expand Up @@ -179,8 +179,8 @@ jobs:
cache-dependency-path: "spec_parser/poetry.lock"
- name: Install dependencies
run: poetry install --sync
- name: Check formatting with black
run: poetry run poe black --check
- name: Check formatting
run: poetry run poe ruff-format --check
- name: Type check with mypy
run: poetry run poe mypy
- name: Lint with ruff
Expand Down
4 changes: 2 additions & 2 deletions domify/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ def _attribute_to_string(x: _T_attribute, case_insensitive: bool) -> str:


def attribute_all(
*funcs: Callable[[_T_attribute], bool]
*funcs: Callable[[_T_attribute], bool],
) -> Callable[[_T_attribute], bool]:
return lambda x: all(f(x) for f in funcs)


def attribute_any(
*funcs: Callable[[_T_attribute], bool]
*funcs: Callable[[_T_attribute], bool],
) -> Callable[[_T_attribute], bool]:
return lambda x: any(f(x) for f in funcs)

Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ dynamic = ["version"]
[project.optional-dependencies]
lint = [
"domify[test]",
"black==24.10.0",
"darglint==1.8.1",
"mypy==1.13.0",
"ruff==0.7.1",
Expand All @@ -56,9 +55,9 @@ packages = ["domify"]
skip-install = true

[tool.hatch.envs.default.scripts]
ruff-fix = "hatch run lint:ruff check domify tests --fix-only --exit-zero {args}"
black = "hatch run lint:black domify tests {args}"
format = ["ruff-fix", "black"]
ruff-fix = "hatch run lint:ruff check domify tests --fix-only {args}"
ruff-format = "hatch run lint:ruff format domify tests {args}"
format = ["ruff-fix", "ruff-format"]

darglint = "hatch run lint:darglint domify tests -v 2 {args}"
mypy = "hatch run lint:mypy domify tests {args}"
Expand Down
111 changes: 1 addition & 110 deletions spec_parser/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions spec_parser/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ warn_unreachable = true


[tool.poe.tasks]
ruff-fix = "ruff check spec_parser --fix-only --exit-zero"
black = "black spec_parser"
format = ["ruff-fix", "black"]
ruff-fix = "ruff check spec_parser --fix-only"
ruff-format = "ruff format spec_parser"
format = ["ruff-fix", "ruff-format"]

mypy = "mypy spec_parser"
ruff = "ruff check spec_parser"
Expand All @@ -39,7 +39,6 @@ beautifulsoup4 = {version = "4.12.3", extras = ["html5lib"]}
requests = "2.32.3"

[tool.poetry.dev-dependencies]
black = "24.10.0"
mypy = "1.13.0"
poethepoet = "0.29.0"
ruff = "0.7.1"
Expand Down
13 changes: 8 additions & 5 deletions spec_parser/spec_parser/rules/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ def parse(content: Tag) -> str:
"Valid floating-point number*",
):
value = "v.attribute_float"
elif content_text in (
"Unordered set of unique space-separated tokens*",
"Unordered set of unique space-separated tokens consisting of IDs*", # TODO
"Unordered set of unique space-separated tokens consisting of valid absolute URLs*", # TODO
"Unordered set of unique space-separated tokens consisting of valid absolute URLs, defined property names, or text*", # TODO
elif (
content_text
in (
"Unordered set of unique space-separated tokens*",
"Unordered set of unique space-separated tokens consisting of IDs*", # TODO
"Unordered set of unique space-separated tokens consisting of valid absolute URLs*", # TODO
"Unordered set of unique space-separated tokens consisting of valid absolute URLs, defined property names, or text*", # TODO
)
):
value = "v.attribute_unique_set"
elif (
Expand Down

0 comments on commit 4f32a00

Please sign in to comment.