From c44926d9380730cb4fe2e41c81320e96b0824cef Mon Sep 17 00:00:00 2001 From: Patrick Golden Date: Tue, 1 Apr 2025 17:39:01 -0400 Subject: [PATCH 1/6] Use `ruff format` for formatting code --- Makefile | 8 +++--- backend/poetry.lock | 59 +----------------------------------------- backend/pyproject.toml | 7 ++--- 3 files changed, 9 insertions(+), 65 deletions(-) diff --git a/Makefile b/Makefile index 27cd40b27..1c299e1de 100644 --- a/Makefile +++ b/Makefile @@ -197,8 +197,8 @@ lint-frontend: .PHONY: lint-backend lint-backend: - $(RUN) ruff check --diff --exit-zero . - $(RUN) black --check --diff -l 120 src tests + -$(RUN) ruff check --diff . + -$(RUN) ruff format --diff . .PHONY: format @@ -207,8 +207,8 @@ format: format-frontend format-backend .PHONY: format-backend format-backend: - $(RUN) ruff check --fix --exit-zero . - $(RUN) black -l 120 src tests + -$(RUN) ruff check --fix . + -$(RUN) ruff format . .PHONY: format-frontend diff --git a/backend/poetry.lock b/backend/poetry.lock index 23746a6e2..90fdf5265 100644 --- a/backend/poetry.lock +++ b/backend/poetry.lock @@ -205,52 +205,6 @@ health = ["click-default-group", "jinja2", "pandas", "pyyaml", "tabulate"] tests = ["coverage", "httpx", "more-itertools", "pytest"] web = ["bootstrap-flask (<=2.0.0)", "curies[fastapi]", "fastapi", "flask (<2.2.4)", "markdown", "pyyaml", "rdflib", "rdflib-endpoint", "rdflib-jsonld", "uvicorn", "werkzeug (<2.3.0)"] -[[package]] -name = "black" -version = "24.4.2" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.8" -files = [ - {file = "black-24.4.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce"}, - {file = "black-24.4.2-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021"}, - {file = "black-24.4.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063"}, - {file = "black-24.4.2-cp310-cp310-win_amd64.whl", hash = "sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96"}, - {file = "black-24.4.2-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474"}, - {file = "black-24.4.2-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c"}, - {file = "black-24.4.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb"}, - {file = "black-24.4.2-cp311-cp311-win_amd64.whl", hash = "sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1"}, - {file = "black-24.4.2-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d"}, - {file = "black-24.4.2-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04"}, - {file = "black-24.4.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc"}, - {file = "black-24.4.2-cp312-cp312-win_amd64.whl", hash = "sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0"}, - {file = "black-24.4.2-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7"}, - {file = "black-24.4.2-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94"}, - {file = "black-24.4.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8"}, - {file = "black-24.4.2-cp38-cp38-win_amd64.whl", hash = "sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c"}, - {file = "black-24.4.2-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1"}, - {file = "black-24.4.2-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741"}, - {file = "black-24.4.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e"}, - {file = "black-24.4.2-cp39-cp39-win_amd64.whl", hash = "sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7"}, - {file = "black-24.4.2-py3-none-any.whl", hash = "sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c"}, - {file = "black-24.4.2.tar.gz", hash = "sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d"}, -] - -[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.7.4)", "aiohttp (>=3.7.4,!=3.9.0)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "blis" version = "0.7.11" @@ -2409,17 +2363,6 @@ files = [ {file = "murmurhash-1.0.10.tar.gz", hash = "sha256:5282aab1317804c6ebd6dd7f69f15ba9075aee671c44a34be2bde0f1b11ef88a"}, ] -[[package]] -name = "mypy-extensions" -version = "1.0.0" -description = "Type system extensions for programs checked with the mypy type checker." -optional = false -python-versions = ">=3.5" -files = [ - {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, - {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, -] - [[package]] name = "ndex2" version = "3.8.0" @@ -5302,4 +5245,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "e4c96e16276d5a535c44767a7b270389e3bd60109bc821182f0b46494075a188" +content-hash = "642e3f29e9c2460d880f99aa6095d5046b7d4615e7b7cbbb6f7aed5cab7ed2bd" diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 3bc590b60..42dcd693b 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -38,7 +38,6 @@ pytest = "^8.2.0" mkdocs = ">=1.6.0" mkdocs-material = ">=9.5.23" mkdocstrings = { version = ">=0.25.1", extras = ["python"] } -black = "^24.4.2" ruff = "*" uvicorn = { extras = ["standard"], version = "^0.29.0" } httpx = "^0.27" @@ -53,11 +52,13 @@ monarch-api = { callable = "monarch_py.api.main:run" } [tool.ruff] line-length = 120 +exclude = ["tests/fixtures/*.py", "src/monarch_py/datamodels/model.py"] +# per-file-ignores = {"" = ""} + +[tool.ruff.lint] ignore = [ "F541", # f-strings with no placeholders ] -exclude = ["tests/fixtures/*.py", "src/monarch_py/datamodels/model.py"] -# per-file-ignores = {"" = ""} [build-system] From ceec9f5e4086ebb37ab728c0b2fbbc8554275d33 Mon Sep 17 00:00:00 2001 From: Patrick Golden Date: Tue, 1 Apr 2025 17:39:27 -0400 Subject: [PATCH 2/6] Formatting changes after moving to `ruff format` --- backend/src/monarch_py/api/search.py | 2 +- backend/src/monarch_py/implementations/solr/solr_query_utils.py | 1 - backend/tests/integration/test_solr_association.py | 1 - backend/tests/unit/test_oak_semsim.py | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/backend/src/monarch_py/api/search.py b/backend/src/monarch_py/api/search.py index a6de19a4c..3b8ea6002 100644 --- a/backend/src/monarch_py/api/search.py +++ b/backend/src/monarch_py/api/search.py @@ -54,7 +54,7 @@ async def autocomplete( default="*:*", title="Query string to autocomplete against", examples=["fanc", "ehler"], - ) + ), ) -> SearchResults: """Autocomplete for entities by label diff --git a/backend/src/monarch_py/implementations/solr/solr_query_utils.py b/backend/src/monarch_py/implementations/solr/solr_query_utils.py index 1dbcaf052..ea12fc6de 100644 --- a/backend/src/monarch_py/implementations/solr/solr_query_utils.py +++ b/backend/src/monarch_py/implementations/solr/solr_query_utils.py @@ -30,7 +30,6 @@ def build_association_query( offset: int = 0, limit: int = 20, ) -> SolrQuery: - entity_fields = ["subject", "object", "disease_context_qualifier"] """Populate a SolrQuery object with association filters""" query = SolrQuery(start=offset, rows=limit) diff --git a/backend/tests/integration/test_solr_association.py b/backend/tests/integration/test_solr_association.py index 3c877d622..4bdd39326 100644 --- a/backend/tests/integration/test_solr_association.py +++ b/backend/tests/integration/test_solr_association.py @@ -68,7 +68,6 @@ def test_entity(): assert response assert response.total > 50 for association in response.items: - if ( association.subject_closure is None or len(association.subject_closure) == 0 ) and association.disease_context_qualifier is None: diff --git a/backend/tests/unit/test_oak_semsim.py b/backend/tests/unit/test_oak_semsim.py index 034164adf..a6ca9010a 100644 --- a/backend/tests/unit/test_oak_semsim.py +++ b/backend/tests/unit/test_oak_semsim.py @@ -5,7 +5,6 @@ @pytest.mark.skip(reason="This is a long running test") def test_semsim_compare(): - subject_ids = ["MP:0010771"] object_ids = ["HP:0004325"] From fbee55144a2e4701b1969ab909c76c813f5eecad Mon Sep 17 00:00:00 2001 From: Glass Date: Tue, 13 May 2025 12:08:53 -0400 Subject: [PATCH 3/6] Run frontend formatting locally --- frontend/src/App.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/App.vue b/frontend/src/App.vue index b2a3fb540..cadeb4bcb 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -10,8 +10,8 @@