diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3b19ab9..db0cec5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 @@ -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 diff --git a/domify/validators.py b/domify/validators.py index d9bdd1f..a053257 100644 --- a/domify/validators.py +++ b/domify/validators.py @@ -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) diff --git a/pyproject.toml b/pyproject.toml index 6506c9f..fbd832a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", @@ -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}" diff --git a/spec_parser/poetry.lock b/spec_parser/poetry.lock index 6117687..7a05042 100644 --- a/spec_parser/poetry.lock +++ b/spec_parser/poetry.lock @@ -22,52 +22,6 @@ charset-normalizer = ["charset-normalizer"] html5lib = ["html5lib"] lxml = ["lxml"] -[[package]] -name = "black" -version = "24.10.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.9" -files = [ - {file = "black-24.10.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e6668650ea4b685440857138e5fe40cde4d652633b1bdffc62933d0db4ed9812"}, - {file = "black-24.10.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:1c536fcf674217e87b8cc3657b81809d3c085d7bf3ef262ead700da345bfa6ea"}, - {file = "black-24.10.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:649fff99a20bd06c6f727d2a27f401331dc0cc861fb69cde910fe95b01b5928f"}, - {file = "black-24.10.0-cp310-cp310-win_amd64.whl", hash = "sha256:fe4d6476887de70546212c99ac9bd803d90b42fc4767f058a0baa895013fbb3e"}, - {file = "black-24.10.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:5a2221696a8224e335c28816a9d331a6c2ae15a2ee34ec857dcf3e45dbfa99ad"}, - {file = "black-24.10.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f9da3333530dbcecc1be13e69c250ed8dfa67f43c4005fb537bb426e19200d50"}, - {file = "black-24.10.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:4007b1393d902b48b36958a216c20c4482f601569d19ed1df294a496eb366392"}, - {file = "black-24.10.0-cp311-cp311-win_amd64.whl", hash = "sha256:394d4ddc64782e51153eadcaaca95144ac4c35e27ef9b0a42e121ae7e57a9175"}, - {file = "black-24.10.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b5e39e0fae001df40f95bd8cc36b9165c5e2ea88900167bddf258bacef9bbdc3"}, - {file = "black-24.10.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d37d422772111794b26757c5b55a3eade028aa3fde43121ab7b673d050949d65"}, - {file = "black-24.10.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:14b3502784f09ce2443830e3133dacf2c0110d45191ed470ecb04d0f5f6fcb0f"}, - {file = "black-24.10.0-cp312-cp312-win_amd64.whl", hash = "sha256:30d2c30dc5139211dda799758559d1b049f7f14c580c409d6ad925b74a4208a8"}, - {file = "black-24.10.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:1cbacacb19e922a1d75ef2b6ccaefcd6e93a2c05ede32f06a21386a04cedb981"}, - {file = "black-24.10.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:1f93102e0c5bb3907451063e08b9876dbeac810e7da5a8bfb7aeb5a9ef89066b"}, - {file = "black-24.10.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ddacb691cdcdf77b96f549cf9591701d8db36b2f19519373d60d31746068dbf2"}, - {file = "black-24.10.0-cp313-cp313-win_amd64.whl", hash = "sha256:680359d932801c76d2e9c9068d05c6b107f2584b2a5b88831c83962eb9984c1b"}, - {file = "black-24.10.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:17374989640fbca88b6a448129cd1745c5eb8d9547b464f281b251dd00155ccd"}, - {file = "black-24.10.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:63f626344343083322233f175aaf372d326de8436f5928c042639a4afbbf1d3f"}, - {file = "black-24.10.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:ccfa1d0cb6200857f1923b602f978386a3a2758a65b52e0950299ea014be6800"}, - {file = "black-24.10.0-cp39-cp39-win_amd64.whl", hash = "sha256:2cd9c95431d94adc56600710f8813ee27eea544dd118d45896bb734e9d7a0dc7"}, - {file = "black-24.10.0-py3-none-any.whl", hash = "sha256:3bb2b7a1f7b685f85b11fed1ef10f8a9148bceb49853e47a294a3dd963c1dd7d"}, - {file = "black-24.10.0.tar.gz", hash = "sha256:846ea64c97afe3bc677b761787993be4991810ecc7a4a937816dd6bddedc4875"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -packaging = ">=22.0" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} -typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.10)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "certifi" version = "2024.8.30" @@ -193,31 +147,6 @@ files = [ {file = "charset_normalizer-3.4.0.tar.gz", hash = "sha256:223217c3d4f82c3ac5e29032b3f1c2eb0fb591b72161f86d93f5719079dae93e"}, ] -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -optional = false -python-versions = ">=3.7" -files = [ - {file = "click-8.1.7-py3-none-any.whl", hash = "sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28"}, - {file = "click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de"}, -] - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - [[package]] name = "html5lib" version = "1.1" @@ -317,17 +246,6 @@ files = [ {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, ] -[[package]] -name = "packaging" -version = "24.1" -description = "Core utilities for Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124"}, - {file = "packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002"}, -] - [[package]] name = "pastel" version = "0.2.1" @@ -339,33 +257,6 @@ files = [ {file = "pastel-0.2.1.tar.gz", hash = "sha256:e6581ac04e973cac858828c6202c1e1e81fee1dc7de7683f3e1ffe0bfd8a573d"}, ] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - -[[package]] -name = "platformdirs" -version = "4.3.6" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a `user data dir`." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb"}, - {file = "platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907"}, -] - -[package.extras] -docs = ["furo (>=2024.8.6)", "proselint (>=0.14)", "sphinx (>=8.0.2)", "sphinx-autodoc-typehints (>=2.4)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=8.3.2)", "pytest-cov (>=5)", "pytest-mock (>=3.14)"] -type = ["mypy (>=1.11.2)"] - [[package]] name = "poethepoet" version = "0.29.0" @@ -584,4 +475,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "93bb7c3a0dfab0390df16e56b75ad42edbfe6d7576c76ff50642c7ada2aa5f38" +content-hash = "c7906bb4640e2e83733a6fe95aa96e884789d68afe903385249f88c6ba3c4283" diff --git a/spec_parser/pyproject.toml b/spec_parser/pyproject.toml index e00b05b..ace3cf1 100644 --- a/spec_parser/pyproject.toml +++ b/spec_parser/pyproject.toml @@ -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" @@ -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" diff --git a/spec_parser/spec_parser/rules/attributes.py b/spec_parser/spec_parser/rules/attributes.py index aebe48a..ee2cc71 100644 --- a/spec_parser/spec_parser/rules/attributes.py +++ b/spec_parser/spec_parser/rules/attributes.py @@ -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 (