diff --git a/.github/workflows/_check-coverage-action.yml b/.github/workflows/_check-coverage-action.yml index cd81d2e..2a396fe 100644 --- a/.github/workflows/_check-coverage-action.yml +++ b/.github/workflows/_check-coverage-action.yml @@ -61,4 +61,30 @@ jobs: uses: actions/upload-artifact@v3 with: name: coverage-report-html - path: htmlcov \ No newline at end of file + path: htmlcov + - name: Upload coverage to Compass + run: | + METRIC_VALUE=$(cat coverage_report.txt | grep 'Total coverage:' | awk '{print $NF}' | sed 's/%//') + curl --request POST \ + --url https://jacksonlaboratory.atlassian.net/gateway/api/compass/v1/metrics \ + --user "${{ vars.ATLASSIAN_COMPASS_EMAIL }}:${{ secrets.ATLASSIAN_COMPASS_KEY }}" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" \ + --data "{ + \"metricSourceId\": \"ari:cloud:compass:44257862-6c68-4d47-8211-da38d2bb001b:metric-source/90bb0329-f6c5-429a-abbc-8d174535ad21/a96140ef-9d79-4015-bb9f-68989e182d48\", + \"value\": $METRIC_VALUE, + \"timestamp\": \"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\" + }" + - name: Upload complexity to Compass + run: | + METRIC_VALUE=$(poetry run radon cc src --total-average | grep 'Average complexity:' | awk '{print $NF}' | sed 's/[\(\)]//g') + curl --request POST \ + --url https://jacksonlaboratory.atlassian.net/gateway/api/compass/v1/metrics \ + --user "${{ vars.ATLASSIAN_COMPASS_EMAIL }}:${{ secrets.ATLASSIAN_COMPASS_KEY }}" \ + --header "Accept: application/json" \ + --header "Content-Type: application/json" \ + --data "{ + \"metricSourceId\": \"ari:cloud:compass:44257862-6c68-4d47-8211-da38d2bb001b:metric-source/90bb0329-f6c5-429a-abbc-8d174535ad21/6f106703-9bc2-49fc-a65e-4f914b9bf878\", + \"value\": $METRIC_VALUE, + \"timestamp\": \"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\" + }" \ No newline at end of file diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ca45173..e0819eb 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -9,6 +9,7 @@ on: jobs: check-coverage: uses: ./.github/workflows/_check-coverage-action.yml + secrets: inherit with: required-coverage: ${{ vars.REQUIRED_COVERAGE }} coverage-module: "geneweaver.db" diff --git a/README.md b/README.md index 9827950..ba28e8e 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,56 @@ The Geneweaver DB library provides database access functionality for the Geneweaver project. The library contains SQL queries wrapped in standard python functions, as well as a database connection manager. + + +## Installation + +To install the Geneweaver DB library, run one of the following commands: + +#### Using Pip +``` +pip install geneweaver-db +``` + +#### Using Poetry +``` +poetry add geneweaver-db +``` + +## Usage +The Geneweaver DB library is intended to be used as a dependency for other Geneweaver +packages, but can also be used as a stand-alone pacakge. + +The package has three main sections: +- `geneweaver.db` - contains non-async database functions. +- `geneweaver.db.aio` - contains async database functions. +- `geneweaver.db.query` - contains SQL queries and SQL generation functions. + +Database functions _usually_ take a `Cursor` or `AsyncCursor` object as their first +argument. + +### Non-Async Functions +```python +import psycopg +import geneweaver +from geneweaver.db.core.settings import settings + +def get_my_gene(): + with psycopg.connect(settings.URI) as conn: + with conn.cursor() as cur: + result = geneweaver.db.gene.get(cur, 'my_gene') + return result +``` + +### Async Functions +```python +import psycopg +import geneweaver +from geneweaver.db.core.settings import settings + +async def get_my_gene(): + async with psycopg.AsyncConnection.connect(settings.URI) as conn: + async with conn.cursor() as cur: + result = await geneweaver.db.aio.gene.get(cur, 'my_gene') + return result +``` \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 4834e10..83fb80c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,34 +1,34 @@ -# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "black" -version = "23.12.1" +version = "24.3.0" description = "The uncompromising code formatter." optional = false python-versions = ">=3.8" files = [ - {file = "black-23.12.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e0aaf6041986767a5e0ce663c7a2f0e9eaf21e6ff87a5f95cbf3675bfd4c41d2"}, - {file = "black-23.12.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c88b3711d12905b74206227109272673edce0cb29f27e1385f33b0163c414bba"}, - {file = "black-23.12.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a920b569dc6b3472513ba6ddea21f440d4b4c699494d2e972a1753cdc25df7b0"}, - {file = "black-23.12.1-cp310-cp310-win_amd64.whl", hash = "sha256:3fa4be75ef2a6b96ea8d92b1587dd8cb3a35c7e3d51f0738ced0781c3aa3a5a3"}, - {file = "black-23.12.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8d4df77958a622f9b5a4c96edb4b8c0034f8434032ab11077ec6c56ae9f384ba"}, - {file = "black-23.12.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:602cfb1196dc692424c70b6507593a2b29aac0547c1be9a1d1365f0d964c353b"}, - {file = "black-23.12.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9c4352800f14be5b4864016882cdba10755bd50805c95f728011bcb47a4afd59"}, - {file = "black-23.12.1-cp311-cp311-win_amd64.whl", hash = "sha256:0808494f2b2df923ffc5723ed3c7b096bd76341f6213989759287611e9837d50"}, - {file = "black-23.12.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:25e57fd232a6d6ff3f4478a6fd0580838e47c93c83eaf1ccc92d4faf27112c4e"}, - {file = "black-23.12.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:2d9e13db441c509a3763a7a3d9a49ccc1b4e974a47be4e08ade2a228876500ec"}, - {file = "black-23.12.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6d1bd9c210f8b109b1762ec9fd36592fdd528485aadb3f5849b2740ef17e674e"}, - {file = "black-23.12.1-cp312-cp312-win_amd64.whl", hash = "sha256:ae76c22bde5cbb6bfd211ec343ded2163bba7883c7bc77f6b756a1049436fbb9"}, - {file = "black-23.12.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:1fa88a0f74e50e4487477bc0bb900c6781dbddfdfa32691e780bf854c3b4a47f"}, - {file = "black-23.12.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:a4d6a9668e45ad99d2f8ec70d5c8c04ef4f32f648ef39048d010b0689832ec6d"}, - {file = "black-23.12.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b18fb2ae6c4bb63eebe5be6bd869ba2f14fd0259bda7d18a46b764d8fb86298a"}, - {file = "black-23.12.1-cp38-cp38-win_amd64.whl", hash = "sha256:c04b6d9d20e9c13f43eee8ea87d44156b8505ca8a3c878773f68b4e4812a421e"}, - {file = "black-23.12.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:3e1b38b3135fd4c025c28c55ddfc236b05af657828a8a6abe5deec419a0b7055"}, - {file = "black-23.12.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4f0031eaa7b921db76decd73636ef3a12c942ed367d8c3841a0739412b260a54"}, - {file = "black-23.12.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:97e56155c6b737854e60a9ab1c598ff2533d57e7506d97af5481141671abf3ea"}, - {file = "black-23.12.1-cp39-cp39-win_amd64.whl", hash = "sha256:dd15245c8b68fe2b6bd0f32c1556509d11bb33aec9b5d0866dd8e2ed3dba09c2"}, - {file = "black-23.12.1-py3-none-any.whl", hash = "sha256:78baad24af0f033958cad29731e27363183e140962595def56423e626f4bee3e"}, - {file = "black-23.12.1.tar.gz", hash = "sha256:4ce3ef14ebe8d9509188014d96af1c456a910d5b5cbf434a09fef7e024b3d0d5"}, + {file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"}, + {file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"}, + {file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"}, + {file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"}, + {file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"}, + {file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"}, + {file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"}, + {file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"}, + {file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"}, + {file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"}, + {file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"}, + {file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"}, + {file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"}, + {file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"}, + {file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"}, + {file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"}, + {file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"}, + {file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"}, + {file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"}, + {file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"}, + {file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"}, + {file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"}, ] [package.dependencies] @@ -182,22 +182,23 @@ pydantic = {version = ">=1.10.7,<2.0.0", extras = ["dotenv"]} [[package]] name = "geneweaver-testing" -version = "0.0.3" +version = "0.1.2" description = "A library to standardize testing of GeneWeaver pacakges." optional = false python-versions = ">=3.8,<4.0" files = [ - {file = "geneweaver_testing-0.0.3-py3-none-any.whl", hash = "sha256:dd9d04cd9ff6366496a9f66ea3347121d0d810d9748936db736837d6f773d7f5"}, - {file = "geneweaver_testing-0.0.3.tar.gz", hash = "sha256:e268462ced2d44ad213cae7cb2e669d5c0065e6bf82965730b7d3eb0f0f0e9a8"}, + {file = "geneweaver_testing-0.1.2-py3-none-any.whl", hash = "sha256:073fca36c9853fcf568398b199179049a241e254d12446bc1d3e25208b686fc0"}, + {file = "geneweaver_testing-0.1.2.tar.gz", hash = "sha256:0a44ab370b4284c61fc1ddbdc32a0ce00881ccc5b9bdfbb6dfd76121fadbe7c8"}, ] [package.dependencies] -black = ">=23.3.0,<24.0.0" +black = ">=24.2.0,<25.0.0" isort = ">=5.12.0,<6.0.0" mypy = ">=1.4.1,<2.0.0" -pytest = ">=7.4.0,<8.0.0" +pytest = ">=7.4.0,<9.0.0" pytest-cov = ">=4.1.0,<5.0.0" -ruff = ">=0.0.277,<0.0.278" +radon = ">=6.0.1,<7.0.0" +ruff = ">=0.2.2,<0.3.0" tomli = ">=2.0.1,<3.0.0" [[package]] @@ -225,6 +226,23 @@ files = [ [package.extras] colors = ["colorama (>=0.4.6)"] +[[package]] +name = "mando" +version = "0.7.1" +description = "Create Python CLI apps with little to no effort at all!" +optional = false +python-versions = "*" +files = [ + {file = "mando-0.7.1-py2.py3-none-any.whl", hash = "sha256:26ef1d70928b6057ee3ca12583d73c63e05c49de8972d620c278a7b206581a8a"}, + {file = "mando-0.7.1.tar.gz", hash = "sha256:18baa999b4b613faefb00eac4efadcf14f510b59b924b66e08289aa1de8c3500"}, +] + +[package.dependencies] +six = "*" + +[package.extras] +restructuredtext = ["rst2ansi"] + [[package]] name = "mypy" version = "1.8.0" @@ -382,8 +400,8 @@ files = [ [package.dependencies] numpy = [ {version = ">=1.20.3", markers = "python_version < \"3.10\""}, - {version = ">=1.21.0", markers = "python_version >= \"3.10\""}, {version = ">=1.23.2", markers = "python_version >= \"3.11\""}, + {version = ">=1.21.0", markers = "python_version >= \"3.10\" and python_version < \"3.11\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -701,30 +719,48 @@ files = [ {file = "pytz-2024.1.tar.gz", hash = "sha256:2a29735ea9c18baf14b448846bde5a48030ed267578472d8955cd0e7443a9812"}, ] +[[package]] +name = "radon" +version = "6.0.1" +description = "Code Metrics in Python" +optional = false +python-versions = "*" +files = [ + {file = "radon-6.0.1-py2.py3-none-any.whl", hash = "sha256:632cc032364a6f8bb1010a2f6a12d0f14bc7e5ede76585ef29dc0cecf4cd8859"}, + {file = "radon-6.0.1.tar.gz", hash = "sha256:d1ac0053943a893878940fedc8b19ace70386fc9c9bf0a09229a44125ebf45b5"}, +] + +[package.dependencies] +colorama = {version = ">=0.4.1", markers = "python_version > \"3.4\""} +mando = ">=0.6,<0.8" + +[package.extras] +toml = ["tomli (>=2.0.1)"] + [[package]] name = "ruff" -version = "0.0.277" -description = "An extremely fast Python linter, written in Rust." +version = "0.2.2" +description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.277-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:3250b24333ef419b7a232080d9724ccc4d2da1dbbe4ce85c4caa2290d83200f8"}, - {file = "ruff-0.0.277-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:3e60605e07482183ba1c1b7237eca827bd6cbd3535fe8a4ede28cbe2a323cb97"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:7baa97c3d7186e5ed4d5d4f6834d759a27e56cf7d5874b98c507335f0ad5aadb"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:74e4b206cb24f2e98a615f87dbe0bde18105217cbcc8eb785bb05a644855ba50"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:479864a3ccd8a6a20a37a6e7577bdc2406868ee80b1e65605478ad3b8eb2ba0b"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:468bfb0a7567443cec3d03cf408d6f562b52f30c3c29df19927f1e0e13a40cd7"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f32ec416c24542ca2f9cc8c8b65b84560530d338aaf247a4a78e74b99cd476b4"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:14a7b2f00f149c5a295f188a643ac25226ff8a4d08f7a62b1d4b0a1dc9f9b85c"}, - {file = "ruff-0.0.277-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a9879f59f763cc5628aa01c31ad256a0f4dc61a29355c7315b83c2a5aac932b5"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:f612e0a14b3d145d90eb6ead990064e22f6f27281d847237560b4e10bf2251f3"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:323b674c98078be9aaded5b8b51c0d9c424486566fb6ec18439b496ce79e5998"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3a43fbe026ca1a2a8c45aa0d600a0116bec4dfa6f8bf0c3b871ecda51ef2b5dd"}, - {file = "ruff-0.0.277-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:734165ea8feb81b0d53e3bf523adc2413fdb76f1264cde99555161dd5a725522"}, - {file = "ruff-0.0.277-py3-none-win32.whl", hash = "sha256:88d0f2afb2e0c26ac1120e7061ddda2a566196ec4007bd66d558f13b374b9efc"}, - {file = "ruff-0.0.277-py3-none-win_amd64.whl", hash = "sha256:6fe81732f788894a00f6ade1fe69e996cc9e485b7c35b0f53fb00284397284b2"}, - {file = "ruff-0.0.277-py3-none-win_arm64.whl", hash = "sha256:2d4444c60f2e705c14cd802b55cd2b561d25bf4311702c463a002392d3116b22"}, - {file = "ruff-0.0.277.tar.gz", hash = "sha256:2dab13cdedbf3af6d4427c07f47143746b6b95d9e4a254ac369a0edb9280a0d2"}, + {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:0a9efb032855ffb3c21f6405751d5e147b0c6b631e3ca3f6b20f917572b97eb6"}, + {file = "ruff-0.2.2-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:d450b7fbff85913f866a5384d8912710936e2b96da74541c82c1b458472ddb39"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ecd46e3106850a5c26aee114e562c329f9a1fbe9e4821b008c4404f64ff9ce73"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5e22676a5b875bd72acd3d11d5fa9075d3a5f53b877fe7b4793e4673499318ba"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1695700d1e25a99d28f7a1636d85bafcc5030bba9d0578c0781ba1790dbcf51c"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:b0c232af3d0bd8f521806223723456ffebf8e323bd1e4e82b0befb20ba18388e"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:f63d96494eeec2fc70d909393bcd76c69f35334cdbd9e20d089fb3f0640216ca"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6a61ea0ff048e06de273b2e45bd72629f470f5da8f71daf09fe481278b175001"}, + {file = "ruff-0.2.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5e1439c8f407e4f356470e54cdecdca1bd5439a0673792dbe34a2b0a551a2fe3"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:940de32dc8853eba0f67f7198b3e79bc6ba95c2edbfdfac2144c8235114d6726"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:0c126da55c38dd917621552ab430213bdb3273bb10ddb67bc4b761989210eb6e"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_i686.whl", hash = "sha256:3b65494f7e4bed2e74110dac1f0d17dc8e1f42faaa784e7c58a98e335ec83d7e"}, + {file = "ruff-0.2.2-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:1ec49be4fe6ddac0503833f3ed8930528e26d1e60ad35c2446da372d16651ce9"}, + {file = "ruff-0.2.2-py3-none-win32.whl", hash = "sha256:d920499b576f6c68295bc04e7b17b6544d9d05f196bb3aac4358792ef6f34325"}, + {file = "ruff-0.2.2-py3-none-win_amd64.whl", hash = "sha256:cc9a91ae137d687f43a44c900e5d95e9617cb37d4c989e462980ba27039d239d"}, + {file = "ruff-0.2.2-py3-none-win_arm64.whl", hash = "sha256:c9d15fc41e6054bfc7200478720570078f0b41c9ae4f010bcc16bd6f4d1aacdd"}, + {file = "ruff-0.2.2.tar.gz", hash = "sha256:e62ed7f36b3068a30ba39193a14274cd706bc486fad521276458022f7bccb31d"}, ] [[package]] @@ -774,4 +810,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "6b0f84318f157ffcd9e49bf5d656c8d09249ebf16c267a799081b234e269895a" +content-hash = "e4df62904ed7598b171712080a2aa22e1fffb805e11921d7c0c61ccf12444609" diff --git a/pyproject.toml b/pyproject.toml index 40c38eb..3a9ac33 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,12 +1,12 @@ [tool.poetry] name = "geneweaver-db" -version = "0.3.0a13" +version = "0.3.0a14" description = "Database Interaction Services for GeneWeaver" authors = ["Jax Computational Sciences "] readme = "README.md" license = "Apache-2.0" -homepage = "https://bergsalex.github.io/geneweaver-docs/" -repository = "https://bitbucket.org/jacksonlaboratory/geneweaver-db" +homepage = "https://thejacksonlaboratory.github.io/geneweaver-docs/" +repository = "https://github.com/TheJacksonLaboratory/geneweaver-db" packages = [ { include = "geneweaver/db", from = "src" }, ] @@ -19,7 +19,7 @@ psycopg = {extras = ["binary"], version = "^3.1.13"} [tool.poetry.group.dev.dependencies] -geneweaver-testing = "^0.0.3" +geneweaver-testing = "^0.1.2" pytest-asyncio = "^0.23.5" [tool.ruff] diff --git a/src/geneweaver/db/__init__.py b/src/geneweaver/db/__init__.py index 9e0d2cd..4329fd0 100644 --- a/src/geneweaver/db/__init__.py +++ b/src/geneweaver/db/__init__.py @@ -1 +1,4 @@ """The root of the geneweaver database package.""" + +# ruff: noqa: F401 +from geneweaver.db import aio, exceptions, gene, geneset, publication, species, user diff --git a/src/geneweaver/db/aio/__init__.py b/src/geneweaver/db/aio/__init__.py index a123b13..8c1fcb9 100644 --- a/src/geneweaver/db/aio/__init__.py +++ b/src/geneweaver/db/aio/__init__.py @@ -1 +1,4 @@ """Async query functions for the database.""" + +# ruff: noqa: F401 +from geneweaver.db.aio import gene, geneset, publication, species diff --git a/src/geneweaver/db/aio/gene.py b/src/geneweaver/db/aio/gene.py index d9ab124..9edab46 100644 --- a/src/geneweaver/db/aio/gene.py +++ b/src/geneweaver/db/aio/gene.py @@ -1,4 +1,5 @@ """Database interaction code relating to Gene IDs.""" + from typing import List, Optional from geneweaver.core.enum import GeneIdentifier, Species diff --git a/src/geneweaver/db/aio/geneset.py b/src/geneweaver/db/aio/geneset.py index 4233b72..4ac8788 100644 --- a/src/geneweaver/db/aio/geneset.py +++ b/src/geneweaver/db/aio/geneset.py @@ -1,4 +1,5 @@ """Async database interaction code relating to Genesets.""" + from typing import List, Optional from geneweaver.core.enum import GeneIdentifier, GenesetTier, Species diff --git a/src/geneweaver/db/aio/publication.py b/src/geneweaver/db/aio/publication.py index 6d230f1..becd1a6 100644 --- a/src/geneweaver/db/aio/publication.py +++ b/src/geneweaver/db/aio/publication.py @@ -1,4 +1,5 @@ """Database code for interacting with Publication table.""" + from typing import Iterable, List, Optional from geneweaver.db.query import publication as publication_query diff --git a/src/geneweaver/db/aio/species.py b/src/geneweaver/db/aio/species.py index c299245..bbecfac 100644 --- a/src/geneweaver/db/aio/species.py +++ b/src/geneweaver/db/aio/species.py @@ -1,4 +1,5 @@ """Species database functions.""" + from typing import List, Optional from geneweaver.core.enum import GeneIdentifier, Species diff --git a/src/geneweaver/db/core/settings.py b/src/geneweaver/db/core/settings.py index 24db056..b285366 100644 --- a/src/geneweaver/db/core/settings.py +++ b/src/geneweaver/db/core/settings.py @@ -1,4 +1,5 @@ """A utility namespace that holds a pre-initialized global configuration object.""" + from .settings_class import Settings settings = Settings() diff --git a/src/geneweaver/db/core/settings_class.py b/src/geneweaver/db/core/settings_class.py index d5e7d19..dd21587 100644 --- a/src/geneweaver/db/core/settings_class.py +++ b/src/geneweaver/db/core/settings_class.py @@ -8,6 +8,7 @@ GWDB_PASSWORD=your_password GWDB_NAME=your_database_name """ + # ruff: noqa: N805, ANN101, ANN401 from typing import Any, Dict, Optional diff --git a/src/geneweaver/db/exceptions.py b/src/geneweaver/db/exceptions.py index eddeef3..b5fa82b 100644 --- a/src/geneweaver/db/exceptions.py +++ b/src/geneweaver/db/exceptions.py @@ -1,4 +1,5 @@ """Exceptions for the geneweaver db module.""" + from geneweaver.core.exc import GeneweaverError diff --git a/src/geneweaver/db/gene.py b/src/geneweaver/db/gene.py index 49d42dc..5abaca9 100644 --- a/src/geneweaver/db/gene.py +++ b/src/geneweaver/db/gene.py @@ -1,4 +1,5 @@ """Database interaction code relating to Gene IDs.""" + from typing import Iterable, List, Optional from geneweaver.core.enum import GeneIdentifier, Species diff --git a/src/geneweaver/db/geneset.py b/src/geneweaver/db/geneset.py index 52783ad..fcd9d11 100644 --- a/src/geneweaver/db/geneset.py +++ b/src/geneweaver/db/geneset.py @@ -1,4 +1,5 @@ """Geneset database functions.""" + from typing import List, Optional from geneweaver.core.enum import GeneIdentifier, GenesetTier, Species diff --git a/src/geneweaver/db/geneset_value.py b/src/geneweaver/db/geneset_value.py index 9cf9c15..cc9804e 100644 --- a/src/geneweaver/db/geneset_value.py +++ b/src/geneweaver/db/geneset_value.py @@ -1,4 +1,5 @@ """Database functions for geneset values.""" + from typing import List, Optional from geneweaver.core.enum import GeneIdentifier diff --git a/src/geneweaver/db/publication.py b/src/geneweaver/db/publication.py index 6bb3f51..e1913cd 100644 --- a/src/geneweaver/db/publication.py +++ b/src/geneweaver/db/publication.py @@ -1,4 +1,5 @@ """Database code for interacting with Publication table.""" + from typing import Iterable, List, Optional from geneweaver.db.query import publication as publication_query diff --git a/src/geneweaver/db/query/gene.py b/src/geneweaver/db/query/gene.py index 16123dc..84e7e4b 100644 --- a/src/geneweaver/db/query/gene.py +++ b/src/geneweaver/db/query/gene.py @@ -1,4 +1,5 @@ """Generate SQL queries to get Gene information.""" + from typing import List, Optional, Tuple from geneweaver.core.enum import GeneIdentifier, Species diff --git a/src/geneweaver/db/query/geneset.py b/src/geneweaver/db/query/geneset.py index 2dd3ccf..249dcdc 100644 --- a/src/geneweaver/db/query/geneset.py +++ b/src/geneweaver/db/query/geneset.py @@ -1,4 +1,5 @@ """SQL query generation code for genesets.""" + from typing import Optional, Tuple from geneweaver.core.enum import GeneIdentifier, GenesetTier, Species diff --git a/src/geneweaver/db/query/publication.py b/src/geneweaver/db/query/publication.py index bdbfb43..02117d1 100644 --- a/src/geneweaver/db/query/publication.py +++ b/src/geneweaver/db/query/publication.py @@ -1,4 +1,5 @@ """Generate SQL queries for publications.""" + from typing import Iterable, Optional, Tuple from geneweaver.db.utils import format_sql_fields diff --git a/src/geneweaver/db/query/search/utils.py b/src/geneweaver/db/query/search/utils.py index 5694912..54b2f7b 100644 --- a/src/geneweaver/db/query/search/utils.py +++ b/src/geneweaver/db/query/search/utils.py @@ -1,4 +1,5 @@ """Functions for generating search queries.""" + from enum import Enum from typing import Tuple diff --git a/src/geneweaver/db/query/species.py b/src/geneweaver/db/query/species.py index 4af716e..7de46cb 100644 --- a/src/geneweaver/db/query/species.py +++ b/src/geneweaver/db/query/species.py @@ -1,4 +1,5 @@ """Generate SQL queries to get Species information.""" + from typing import Optional, Tuple from geneweaver.core.enum import GeneIdentifier, Species diff --git a/src/geneweaver/db/query/utils.py b/src/geneweaver/db/query/utils.py index 9d79a1d..3f84162 100644 --- a/src/geneweaver/db/query/utils.py +++ b/src/geneweaver/db/query/utils.py @@ -1,4 +1,5 @@ """Utility functions for the SQL generation functions.""" + from typing import Dict, List, Optional, Tuple, Union from psycopg.sql import SQL, Composed diff --git a/src/geneweaver/db/species.py b/src/geneweaver/db/species.py index ac8c90d..51269de 100644 --- a/src/geneweaver/db/species.py +++ b/src/geneweaver/db/species.py @@ -1,4 +1,5 @@ """Species database functions.""" + from typing import List, Optional from geneweaver.core.enum import GeneIdentifier, Species diff --git a/src/geneweaver/db/user.py b/src/geneweaver/db/user.py index 7f5c138..0b27ae2 100644 --- a/src/geneweaver/db/user.py +++ b/src/geneweaver/db/user.py @@ -18,6 +18,7 @@ - user_id_from_api_key - user_id_from_sso_id """ + from typing import List, Optional from geneweaver.db.utils import temp_override_row_factory diff --git a/src/geneweaver/db/utils.py b/src/geneweaver/db/utils.py index c78dc4d..57bcdaf 100644 --- a/src/geneweaver/db/utils.py +++ b/src/geneweaver/db/utils.py @@ -1,4 +1,5 @@ """Utilities for the GeneWeaver database functions.""" + # ruff: noqa: ANN001, ANN002, ANN003, ANN201, ANN202 import functools from typing import List, Optional diff --git a/tests/conftest.py b/tests/conftest.py index c7ed933..0f5b888 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,4 +2,5 @@ These fixtures are available to be used by all tests in the unit test suite. """ + from geneweaver.testing.fixtures import * # noqa: F403 diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 5a5f9d3..7eb89c1 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -1,4 +1,5 @@ """Fixtures for all db unit tests.""" + import random from unittest.mock import AsyncMock, MagicMock diff --git a/tests/unit/const.py b/tests/unit/const.py index f29bb7c..7d93583 100644 --- a/tests/unit/const.py +++ b/tests/unit/const.py @@ -1,4 +1,5 @@ """Const values for all db unit tests.""" + import inspect from psycopg import errors diff --git a/tests/unit/core/test_settings_class.py b/tests/unit/core/test_settings_class.py index 9c0ff63..cff1e61 100644 --- a/tests/unit/core/test_settings_class.py +++ b/tests/unit/core/test_settings_class.py @@ -1,4 +1,5 @@ """Test the GeneWeaver Database module's settings class.""" + from geneweaver.db.core.settings_class import Settings from pydantic import BaseModel, PostgresDsn diff --git a/tests/unit/gene/conftest.py b/tests/unit/gene/conftest.py index bb4a767..55dde15 100644 --- a/tests/unit/gene/conftest.py +++ b/tests/unit/gene/conftest.py @@ -1,4 +1,5 @@ """Fixtures for the gene db tests.""" + import random from typing import List diff --git a/tests/unit/gene/const.py b/tests/unit/gene/const.py index 532a02d..b3bbe25 100644 --- a/tests/unit/gene/const.py +++ b/tests/unit/gene/const.py @@ -1,4 +1,5 @@ """Gene ID constants for testing.""" + from datetime import datetime # This example was taken straight from the database on July 18, 2023. diff --git a/tests/unit/gene/test_gene_database_by_id.py b/tests/unit/gene/test_gene_database_by_id.py index 0227f15..e6495bb 100644 --- a/tests/unit/gene/test_gene_database_by_id.py +++ b/tests/unit/gene/test_gene_database_by_id.py @@ -1,4 +1,5 @@ """Test the gene.gene_database_by_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/gene/test_gene_database_id.py b/tests/unit/gene/test_gene_database_id.py index 5aa5185..1b39ddc 100644 --- a/tests/unit/gene/test_gene_database_id.py +++ b/tests/unit/gene/test_gene_database_id.py @@ -1,4 +1,5 @@ """Test the get_database_id function.""" + from geneweaver.core.enum import GeneIdentifier from geneweaver.db.gene import gene_database_id diff --git a/tests/unit/gene/test_get.py b/tests/unit/gene/test_get.py index 42b7aa2..17b2983 100644 --- a/tests/unit/gene/test_get.py +++ b/tests/unit/gene/test_get.py @@ -1,4 +1,5 @@ """Test the get db exec functions (sync and async).""" + from geneweaver.core.enum import Species from geneweaver.db.aio.gene import get as async_get from geneweaver.db.gene import get diff --git a/tests/unit/gene/test_get_homolog_ids.py b/tests/unit/gene/test_get_homolog_ids.py index bd9424f..f6f8f1b 100644 --- a/tests/unit/gene/test_get_homolog_ids.py +++ b/tests/unit/gene/test_get_homolog_ids.py @@ -1,4 +1,5 @@ """Test the get_homolog_ids function.""" + from unittest.mock import Mock, patch import pytest diff --git a/tests/unit/gene/test_get_homolog_ids_by_ode_id.py b/tests/unit/gene/test_get_homolog_ids_by_ode_id.py index a9e36b5..96e7a28 100644 --- a/tests/unit/gene/test_get_homolog_ids_by_ode_id.py +++ b/tests/unit/gene/test_get_homolog_ids_by_ode_id.py @@ -1,4 +1,5 @@ """Test the get_homolog_ids_by_ode_id function.""" + from geneweaver.core.enum import GeneIdentifier from geneweaver.db.gene import get_homolog_ids_by_ode_id diff --git a/tests/unit/gene/test_get_preferred.py b/tests/unit/gene/test_get_preferred.py index b4af049..ca63ffe 100644 --- a/tests/unit/gene/test_get_preferred.py +++ b/tests/unit/gene/test_get_preferred.py @@ -1,4 +1,5 @@ """Test the get_preferred db exec functions (sync and async).""" + from geneweaver.core.enum import Species from geneweaver.db.aio.gene import get_preferred as async_get_preferred from geneweaver.db.gene import get_preferred diff --git a/tests/unit/gene/test_id_types.py b/tests/unit/gene/test_id_types.py index 11622a9..9144edd 100644 --- a/tests/unit/gene/test_id_types.py +++ b/tests/unit/gene/test_id_types.py @@ -1,4 +1,5 @@ """Test the get_gene_id_types function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/gene/test_info_by_id.py b/tests/unit/gene/test_info_by_id.py index 79d362f..f63447d 100644 --- a/tests/unit/gene/test_info_by_id.py +++ b/tests/unit/gene/test_info_by_id.py @@ -1,4 +1,5 @@ """Test the gene.info_by_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/gene/test_mapping.py b/tests/unit/gene/test_mapping.py index 6e9e322..9b47d45 100644 --- a/tests/unit/gene/test_mapping.py +++ b/tests/unit/gene/test_mapping.py @@ -1,4 +1,5 @@ """Test the mapping gene db exec functions (sync and async).""" + from geneweaver.core.enum import GeneIdentifier, Species from geneweaver.db.aio.gene import mapping as async_mapping from geneweaver.db.gene import mapping diff --git a/tests/unit/gene/test_symbols_by_geneset_id.py b/tests/unit/gene/test_symbols_by_geneset_id.py index 37f1302..804e2c7 100644 --- a/tests/unit/gene/test_symbols_by_geneset_id.py +++ b/tests/unit/gene/test_symbols_by_geneset_id.py @@ -1,4 +1,5 @@ """Test the gene.symbols_by_geneset_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/gene/test_symbols_by_project_id.py b/tests/unit/gene/test_symbols_by_project_id.py index 81db67a..b02372e 100644 --- a/tests/unit/gene/test_symbols_by_project_id.py +++ b/tests/unit/gene/test_symbols_by_project_id.py @@ -1,4 +1,5 @@ """Test the gene.symbols_by_project_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/geneset/test_by_owner_id.py b/tests/unit/geneset/test_by_owner_id.py index 90c2479..8360c7e 100644 --- a/tests/unit/geneset/test_by_owner_id.py +++ b/tests/unit/geneset/test_by_owner_id.py @@ -1,4 +1,5 @@ """Test the geneset.by_owner_id function.""" + import pytest from geneweaver.db.aio.geneset import by_owner_id as async_by_owner_id from geneweaver.db.geneset import by_owner_id diff --git a/tests/unit/geneset/test_by_project_id.py b/tests/unit/geneset/test_by_project_id.py index 217949a..9b511a6 100644 --- a/tests/unit/geneset/test_by_project_id.py +++ b/tests/unit/geneset/test_by_project_id.py @@ -1,4 +1,5 @@ """Test the geneset.by_project_id function.""" + import pytest from geneweaver.db.aio.geneset import by_project_id as async_by_project_id from geneweaver.db.geneset import by_project_id diff --git a/tests/unit/geneset/test_get.py b/tests/unit/geneset/test_get.py index 2ff68d7..86e5f1e 100644 --- a/tests/unit/geneset/test_get.py +++ b/tests/unit/geneset/test_get.py @@ -1,4 +1,5 @@ """Test the general geneset.get function.""" + from geneweaver.db.aio.geneset import get as async_get from geneweaver.db.geneset import get diff --git a/tests/unit/geneset/test_homology_ids.py b/tests/unit/geneset/test_homology_ids.py index 7372248..1e2bd7f 100644 --- a/tests/unit/geneset/test_homology_ids.py +++ b/tests/unit/geneset/test_homology_ids.py @@ -1,4 +1,5 @@ """Test the geneset.homology_ids function.""" + import pytest from geneweaver.db.geneset import homology_ids diff --git a/tests/unit/geneset/test_is_readable.py b/tests/unit/geneset/test_is_readable.py index da0bccd..ff27750 100644 --- a/tests/unit/geneset/test_is_readable.py +++ b/tests/unit/geneset/test_is_readable.py @@ -1,4 +1,5 @@ """Test the geneset.is_readable function.""" + import pytest from geneweaver.db.geneset import is_readable diff --git a/tests/unit/geneset/test_tier.py b/tests/unit/geneset/test_tier.py index d2e278e..0e145f9 100644 --- a/tests/unit/geneset/test_tier.py +++ b/tests/unit/geneset/test_tier.py @@ -1,4 +1,5 @@ """Test the geneset.tier function.""" + from geneweaver.db.geneset import tier from tests.unit.testing_utils import ( diff --git a/tests/unit/geneset/test_update_date.py b/tests/unit/geneset/test_update_date.py index 5209d47..3b9f3a0 100644 --- a/tests/unit/geneset/test_update_date.py +++ b/tests/unit/geneset/test_update_date.py @@ -1,4 +1,5 @@ """Test the geneset.update_date function.""" + import pytest from geneweaver.db.geneset import update_date diff --git a/tests/unit/geneset/test_user_is_owner.py b/tests/unit/geneset/test_user_is_owner.py index 9b26461..e089c9d 100644 --- a/tests/unit/geneset/test_user_is_owner.py +++ b/tests/unit/geneset/test_user_is_owner.py @@ -1,4 +1,5 @@ """Test the geneset.user_is_owner function.""" + import pytest from geneweaver.db.geneset import user_is_owner diff --git a/tests/unit/geneset_value/test_by_geneset_id.py b/tests/unit/geneset_value/test_by_geneset_id.py index 57bb8b4..34aadb8 100644 --- a/tests/unit/geneset_value/test_by_geneset_id.py +++ b/tests/unit/geneset_value/test_by_geneset_id.py @@ -1,4 +1,5 @@ """Test the geneset_values.by_genest_id function.""" + from unittest.mock import patch import pytest diff --git a/tests/unit/geneset_value/test_by_geneset_id_and_identifier.py b/tests/unit/geneset_value/test_by_geneset_id_and_identifier.py index 4349a90..07d7a19 100644 --- a/tests/unit/geneset_value/test_by_geneset_id_and_identifier.py +++ b/tests/unit/geneset_value/test_by_geneset_id_and_identifier.py @@ -1,4 +1,5 @@ """Test the by_geneset_id_and_identifier function.""" + from geneweaver.core.enum import GeneIdentifier from geneweaver.db.geneset_value import by_geneset_id_and_identifier diff --git a/tests/unit/geneset_value/test_by_geneset_id_as_uploaded.py b/tests/unit/geneset_value/test_by_geneset_id_as_uploaded.py index a7a6d85..a11e19a 100644 --- a/tests/unit/geneset_value/test_by_geneset_id_as_uploaded.py +++ b/tests/unit/geneset_value/test_by_geneset_id_as_uploaded.py @@ -1,4 +1,5 @@ """Test the geneset_values.by_genest_id function.""" + import pytest from geneweaver.db.geneset_value import by_geneset_id_as_uploaded diff --git a/tests/unit/geneset_value/test_format_geneset_values_for_file_insert.py b/tests/unit/geneset_value/test_format_geneset_values_for_file_insert.py index 4c2e397..9dce0e3 100644 --- a/tests/unit/geneset_value/test_format_geneset_values_for_file_insert.py +++ b/tests/unit/geneset_value/test_format_geneset_values_for_file_insert.py @@ -1,4 +1,5 @@ """Test the format_geneset_values_for_file_insert function.""" + import pytest from geneweaver.db.geneset_value import ( GenesetValueInput, diff --git a/tests/unit/geneset_value/test_get_file.py b/tests/unit/geneset_value/test_get_file.py index 0aae4dd..deaa4d8 100644 --- a/tests/unit/geneset_value/test_get_file.py +++ b/tests/unit/geneset_value/test_get_file.py @@ -1,4 +1,5 @@ """Test the geneset_values.get_file function.""" + import pytest from geneweaver.db.geneset_value import get_file diff --git a/tests/unit/geneset_value/test_insert_file.py b/tests/unit/geneset_value/test_insert_file.py index c8fc790..26b3416 100644 --- a/tests/unit/geneset_value/test_insert_file.py +++ b/tests/unit/geneset_value/test_insert_file.py @@ -1,4 +1,5 @@ """Test the database interaction for inserting a geneset values file.""" + import pytest from geneweaver.db.exceptions import GeneweaverTypeError from geneweaver.db.geneset_value import insert_file diff --git a/tests/unit/geneset_value/test_insert_geneset_value.py b/tests/unit/geneset_value/test_insert_geneset_value.py index a493591..ed4095c 100644 --- a/tests/unit/geneset_value/test_insert_geneset_value.py +++ b/tests/unit/geneset_value/test_insert_geneset_value.py @@ -1,4 +1,5 @@ """Test the insert_geneset_value function.""" + import pytest from geneweaver.db.geneset_value import insert_geneset_value diff --git a/tests/unit/publication/const.py b/tests/unit/publication/const.py index 02061ef..e34d104 100644 --- a/tests/unit/publication/const.py +++ b/tests/unit/publication/const.py @@ -1,6 +1,5 @@ """Constants for the publication unit tests.""" - PUBMED_PUBLICATIONS = [ ( 123456, diff --git a/tests/unit/publication/test_by_geneset_id.py b/tests/unit/publication/test_by_geneset_id.py index f1b9d72..e1b2f00 100644 --- a/tests/unit/publication/test_by_geneset_id.py +++ b/tests/unit/publication/test_by_geneset_id.py @@ -1,4 +1,5 @@ """Test the publication.by_geneset_id function.""" + from geneweaver.db.aio.publication import by_geneset_id as async_by_geneset_id from geneweaver.db.publication import by_geneset_id diff --git a/tests/unit/publication/test_by_id.py b/tests/unit/publication/test_by_id.py index a433aa4..07404db 100644 --- a/tests/unit/publication/test_by_id.py +++ b/tests/unit/publication/test_by_id.py @@ -1,4 +1,5 @@ """Test the publication.by_id function.""" + from geneweaver.db.aio.publication import by_id as async_by_id from geneweaver.db.publication import by_id diff --git a/tests/unit/publication/test_by_pubmed_id.py b/tests/unit/publication/test_by_pubmed_id.py index f53ec45..8fc5425 100644 --- a/tests/unit/publication/test_by_pubmed_id.py +++ b/tests/unit/publication/test_by_pubmed_id.py @@ -1,4 +1,5 @@ """Test the get_publication_by_pubmed_id function.""" + import pytest from geneweaver.db.aio.publication import by_pubmed_id as async_by_pubmed_id from geneweaver.db.publication import by_pubmed_id diff --git a/tests/unit/publication/test_by_pubmed_ids.py b/tests/unit/publication/test_by_pubmed_ids.py index 7a378c1..21fe80c 100644 --- a/tests/unit/publication/test_by_pubmed_ids.py +++ b/tests/unit/publication/test_by_pubmed_ids.py @@ -1,4 +1,5 @@ """Test the test_get_publications_by_pubmed_ids function.""" + import random import pytest diff --git a/tests/unit/query/gene/test_get.py b/tests/unit/query/gene/test_get.py index 880cb3d..7095323 100644 --- a/tests/unit/query/gene/test_get.py +++ b/tests/unit/query/gene/test_get.py @@ -1,4 +1,5 @@ """Test the gene `get` query function generation function.""" + import pytest from geneweaver.core.enum import GeneIdentifier, Species from geneweaver.db.query.gene import get diff --git a/tests/unit/query/geneset/test_format_select_query.py b/tests/unit/query/geneset/test_format_select_query.py index cf3253a..46a50a2 100644 --- a/tests/unit/query/geneset/test_format_select_query.py +++ b/tests/unit/query/geneset/test_format_select_query.py @@ -1,4 +1,5 @@ """Test the format_select_query sql generation function.""" + # ruff: noqa: C901 import pytest from geneweaver.db.query.geneset import GENESET_FIELDS_MAP, format_select_query diff --git a/tests/unit/query/geneset/test_search.py b/tests/unit/query/geneset/test_search.py index 9c0d6a1..1973ad1 100644 --- a/tests/unit/query/geneset/test_search.py +++ b/tests/unit/query/geneset/test_search.py @@ -1,4 +1,5 @@ """Test the internal _search function for geneset sql generation.""" + import pytest from geneweaver.db.query.geneset import _search diff --git a/tests/unit/query/search/utils/test_enums.py b/tests/unit/query/search/utils/test_enums.py index 1536797..aec1074 100644 --- a/tests/unit/query/search/utils/test_enums.py +++ b/tests/unit/query/search/utils/test_enums.py @@ -1,4 +1,5 @@ """Tests for the search query util enums module.""" + import pytest from geneweaver.db.query.search.utils import ( QueryType, diff --git a/tests/unit/query/search/utils/test_search_query.py b/tests/unit/query/search/utils/test_search_query.py index 7514142..f0f7261 100644 --- a/tests/unit/query/search/utils/test_search_query.py +++ b/tests/unit/query/search/utils/test_search_query.py @@ -1,4 +1,5 @@ """Test the query generation search_query util function.""" + import pytest from geneweaver.db.query.search.utils import search_query diff --git a/tests/unit/query/species/test_get.py b/tests/unit/query/species/test_get.py index 98b4516..95bf14b 100644 --- a/tests/unit/query/species/test_get.py +++ b/tests/unit/query/species/test_get.py @@ -1,4 +1,5 @@ """Test the species `get` query function generation function.""" + import pytest from geneweaver.core.enum import GeneIdentifier, Species from geneweaver.db.query.species import get diff --git a/tests/unit/species/test_get.py b/tests/unit/species/test_get.py index d27b42b..ad832ea 100644 --- a/tests/unit/species/test_get.py +++ b/tests/unit/species/test_get.py @@ -1,4 +1,5 @@ """Test the species get_by_id function (sync and async).""" + from geneweaver.db.aio.species import get as async_get from geneweaver.db.species import get diff --git a/tests/unit/species/test_get_by_id.py b/tests/unit/species/test_get_by_id.py index cf6c8a9..bbfe1e5 100644 --- a/tests/unit/species/test_get_by_id.py +++ b/tests/unit/species/test_get_by_id.py @@ -1,4 +1,5 @@ """Test the species get_by_id function (sync and async).""" + from geneweaver.db.aio.species import get_by_id as async_get_by_id from geneweaver.db.species import get_by_id diff --git a/tests/unit/testing_utils.py b/tests/unit/testing_utils.py index 41c77f1..32dbb35 100644 --- a/tests/unit/testing_utils.py +++ b/tests/unit/testing_utils.py @@ -1,4 +1,5 @@ """Utilities for testing the database module.""" + # ruff: noqa: ANN002, ANN003, ANN101, D102, D107 from typing import Callable from unittest.mock import MagicMock diff --git a/tests/unit/user/const.py b/tests/unit/user/const.py index 04c4527..368da55 100644 --- a/tests/unit/user/const.py +++ b/tests/unit/user/const.py @@ -1,4 +1,5 @@ """Example data that matches the production.usr table schema.""" + from datetime import datetime, timedelta MOCK_USER_DATA = [ diff --git a/tests/unit/user/test_by_api_key.py b/tests/unit/user/test_by_api_key.py index 300ad5a..d185ff0 100644 --- a/tests/unit/user/test_by_api_key.py +++ b/tests/unit/user/test_by_api_key.py @@ -1,4 +1,5 @@ """Test for the user.by_api_key function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/user/test_by_email.py b/tests/unit/user/test_by_email.py index e5f84d0..6dcff0e 100644 --- a/tests/unit/user/test_by_email.py +++ b/tests/unit/user/test_by_email.py @@ -1,4 +1,5 @@ """Test for the user.by_email function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/user/test_by_sso_id.py b/tests/unit/user/test_by_sso_id.py index 3cec1e4..7f550fd 100644 --- a/tests/unit/user/test_by_sso_id.py +++ b/tests/unit/user/test_by_sso_id.py @@ -1,4 +1,5 @@ """Test for the user.by_sso_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/user/test_by_sso_id_and_email.py b/tests/unit/user/test_by_sso_id_and_email.py index 6d2d891..8a91b4f 100644 --- a/tests/unit/user/test_by_sso_id_and_email.py +++ b/tests/unit/user/test_by_sso_id_and_email.py @@ -1,4 +1,5 @@ """Test for the user.by_sso_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/user/test_by_user_id.py b/tests/unit/user/test_by_user_id.py index 48327b2..0ac7976 100644 --- a/tests/unit/user/test_by_user_id.py +++ b/tests/unit/user/test_by_user_id.py @@ -1,4 +1,5 @@ """Test for the user.by_user_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/user/test_create_sso_user.py b/tests/unit/user/test_create_sso_user.py index 55db273..66501b1 100644 --- a/tests/unit/user/test_create_sso_user.py +++ b/tests/unit/user/test_create_sso_user.py @@ -1,4 +1,5 @@ """Test the create_sso_user function.""" + from geneweaver.db.user import create_sso_user from tests.unit.testing_utils import ( diff --git a/tests/unit/user/test_email_exists.py b/tests/unit/user/test_email_exists.py index 910fac2..6878aab 100644 --- a/tests/unit/user/test_email_exists.py +++ b/tests/unit/user/test_email_exists.py @@ -1,4 +1,5 @@ """Test the sso_id_exists function.""" + from geneweaver.db.user import email_exists from tests.unit.testing_utils import ( diff --git a/tests/unit/user/test_link_user_id_with_sso_id.py b/tests/unit/user/test_link_user_id_with_sso_id.py index af7be8c..718f472 100644 --- a/tests/unit/user/test_link_user_id_with_sso_id.py +++ b/tests/unit/user/test_link_user_id_with_sso_id.py @@ -1,4 +1,5 @@ """Test the link_user_id_with_sso_id function.""" + from unittest.mock import patch import pytest diff --git a/tests/unit/user/test_sso_id_exists.py b/tests/unit/user/test_sso_id_exists.py index 22d63a5..a32394e 100644 --- a/tests/unit/user/test_sso_id_exists.py +++ b/tests/unit/user/test_sso_id_exists.py @@ -1,4 +1,5 @@ """Test the sso_id_exists function.""" + from geneweaver.db.user import sso_id_exists from tests.unit.testing_utils import ( diff --git a/tests/unit/user/test_user_id_from_api_key.py b/tests/unit/user/test_user_id_from_api_key.py index d1fbba1..d1f2525 100644 --- a/tests/unit/user/test_user_id_from_api_key.py +++ b/tests/unit/user/test_user_id_from_api_key.py @@ -1,4 +1,5 @@ """Test for the user.user_id_from_api_key function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/user/test_user_id_from_sso_id.py b/tests/unit/user/test_user_id_from_sso_id.py index ec97ca4..9572191 100644 --- a/tests/unit/user/test_user_id_from_sso_id.py +++ b/tests/unit/user/test_user_id_from_sso_id.py @@ -1,4 +1,5 @@ """Test for the user.user_id_from_sso_id function.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/utils/test_temp_override_row_factory.py b/tests/unit/utils/test_temp_override_row_factory.py index 24d5cc6..e3254c4 100644 --- a/tests/unit/utils/test_temp_override_row_factory.py +++ b/tests/unit/utils/test_temp_override_row_factory.py @@ -1,4 +1,5 @@ """Test the temp_override_row_factory decorator.""" + from unittest.mock import Mock import pytest diff --git a/tests/unit/utils/test_unpack_one_item_fetchall_results.py b/tests/unit/utils/test_unpack_one_item_fetchall_results.py index a5cb084..30ea0be 100644 --- a/tests/unit/utils/test_unpack_one_item_fetchall_results.py +++ b/tests/unit/utils/test_unpack_one_item_fetchall_results.py @@ -1,4 +1,5 @@ """Test the unpack_one_item_fetchall_results function.""" + import pytest from geneweaver.db.exceptions import GeneweaverDoesNotExistError, GeneweaverValueError from geneweaver.db.utils import unpack_one_item_fetchall_results