diff options
| -rw-r--r-- | .pre-commit-config.yaml | 21 | ||||
| -rw-r--r-- | poetry.lock | 147 | ||||
| -rw-r--r-- | pyproject.toml | 4 | ||||
| -rw-r--r-- | requirements.txt | 12 | ||||
| -rw-r--r-- | src/lib/szurubooru.py | 121 |
5 files changed, 165 insertions, 140 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3bae5dd..85dac3e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,19 +1,25 @@ repos: -- repo: https://github.com/python-poetry/poetry - rev: 'master' - hooks: +- repo: https://github.com/python-poetry/poetry + rev: 'master' + hooks: - id: poetry-check - id: poetry-install - id: poetry-lock - id: poetry-export -- repo: https://github.com/psf/black - rev: 23.9.1 - hooks: +- repo: https://github.com/psf/black + rev: 23.9.1 + hooks: - id: black +- repo: https://github.com/pycqa/pydocstyle + rev: 6.3.0 + hooks: + - id: pydocstyle + + - repo: local hooks: - id: pylint @@ -32,5 +38,4 @@ repos: entry: poetry run pytype language: system types: [python] - pass_filenames: false - args: ["--keep-going", "src"] + args: ["--keep-going"] diff --git a/poetry.lock b/poetry.lock index 8d564a7..6921e85 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.6.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.0.dev0 and should not be changed by hand. [[package]] name = "about-time" @@ -28,13 +28,13 @@ grapheme = "0.6.0" [[package]] name = "annotated-types" -version = "0.5.0" +version = "0.6.0" description = "Reusable constraint types to use with typing.Annotated" optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "annotated_types-0.5.0-py3-none-any.whl", hash = "sha256:58da39888f92c276ad970249761ebea80ba544b77acddaa1a4d6cf78287d45fd"}, - {file = "annotated_types-0.5.0.tar.gz", hash = "sha256:47cdc3490d9ac1506ce92c7aaa76c579dc3509ff11e098fc867e5130ab7be802"}, + {file = "annotated_types-0.6.0-py3-none-any.whl", hash = "sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43"}, + {file = "annotated_types-0.6.0.tar.gz", hash = "sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d"}, ] [[package]] @@ -202,13 +202,13 @@ files = [ [[package]] name = "importlab" -version = "0.8" +version = "0.8.1" description = "A library to calculate python dependency graphs." optional = false python-versions = ">=3.6.0" files = [ - {file = "importlab-0.8-py2.py3-none-any.whl", hash = "sha256:a009ccde7b549b16f3e6b034fea748febc8d45ded9e8a09370a8f994acfda25b"}, - {file = "importlab-0.8.tar.gz", hash = "sha256:b24b3aac3b073966ae42fb2d3a7764f3377b30bb72c0d411fe29134cc9276e86"}, + {file = "importlab-0.8.1-py2.py3-none-any.whl", hash = "sha256:124cfa00e8a34fefe8aac1a5e94f56c781b178c9eb61a1d3f60f7e03b77338d3"}, + {file = "importlab-0.8.1.tar.gz", hash = "sha256:b3893853b1f6eb027da509c3b40e6787e95dd66b4b66f1b3613aad77556e1465"}, ] [package.dependencies] @@ -233,41 +233,42 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "libcst" -version = "1.0.1" +version = "1.1.0" description = "A concrete syntax tree with AST-like properties for Python 3.5, 3.6, 3.7, 3.8, 3.9, and 3.10 programs." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "libcst-1.0.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:80423311f09fc5fc3270ede44d30d9d8d3c2d3dd50dbf703a581ca7346949fa6"}, - {file = "libcst-1.0.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9d6dec2a3c443792e6af7c36fadc256e4ea586214c76b52f0d18118811dbe351"}, - {file = "libcst-1.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4840a3de701778f0a19582bb3085c61591329153f801dc25da84689a3733960b"}, - {file = "libcst-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0138068baf09561268c7f079373bda45f0e2b606d2d19df1307ca8a5134fc465"}, - {file = "libcst-1.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:9a4931feceab171e6fce73de94e13880424367247dad6ff2b49cabfec733e144"}, - {file = "libcst-1.0.1-cp310-cp310-win_amd64.whl", hash = "sha256:47dba43855e9c7b06d8b256ee81f0ebec6a4f43605456519577e09dfe4b4288c"}, - {file = "libcst-1.0.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8c50541c3fd6b1d5a3765c4bb5ee8ecbba9d0e798e48f79fd5adf3b6752de4d0"}, - {file = "libcst-1.0.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:5599166d5fec40e18601fb8868519dde99f77b6e4ad6074958018f9545da7abd"}, - {file = "libcst-1.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:600c4d3a9a2f75d5a055fed713a5a4d812709947909610aa6527abe08a31896f"}, - {file = "libcst-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a6b5aea04c35e13109edad3cf83bc6dcd74309b150a781d2189eecb288b73a87"}, - {file = "libcst-1.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ddd4e0eeec499d1c824ab545e62e957dbbd69a16bc4273208817638eb7d6b3c6"}, - {file = "libcst-1.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:414350df5e334ddf0db1732d63da44e81b734d45abe1c597b5e5c0dd46aa4156"}, - {file = "libcst-1.0.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:1adcfa7cafb6a0d39a1a0bec541355608038b45815e0c5019c95f91921d42884"}, - {file = "libcst-1.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8d31ce2790eab59c1bd8e33fe72d09cfc78635c145bdc3f08296b360abb5f443"}, - {file = "libcst-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:f2cb687e1514625e91024e50a5d2e485c0ad3be24f199874ebf32b5de0346150"}, - {file = "libcst-1.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6caa33430c0c7a0fcad921b0deeec61ddb96796b6f88dca94966f6db62065f4f"}, - {file = "libcst-1.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:b97f652b15c50e91df411a9c8d5e6f75882b30743a49b387dcedd3f68ed94d75"}, - {file = "libcst-1.0.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:967c66fabd52102954207bf1541312b467afc210fdf7033f32da992fb6c2372c"}, - {file = "libcst-1.0.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:b666a605f4205c8357696f3b6571a38f6a8537cdcbb8f357587d35168298af34"}, - {file = "libcst-1.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:ae49dcbfadefb82e830d41d9f0a1db0af3b771224768f431f1b7b3a9803ed7e3"}, - {file = "libcst-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c90c74a8a314f0774f045122323fb60bacba79cbf5f71883c0848ecd67179541"}, - {file = "libcst-1.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b0533de4e35396c61aeb3a6266ac30369a855910c2385aaa902ff4aabd60d409"}, - {file = "libcst-1.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:5e3293e77657ba62533553bb9f0c5fb173780e164c65db1ea2a3e0d03944a284"}, - {file = "libcst-1.0.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:119ba709f1dcb785a4458cf36cedb51d6f9cb2eec0acd7bb171f730eac7cb6ce"}, - {file = "libcst-1.0.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:4b4e336f6d68456017671cdda8ddebf9caebce8052cc21a3f494b03d7bd28386"}, - {file = "libcst-1.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8420926791b0b6206cb831a7ec73d26ae820e65bdf07ce9813c7754c7722c07a"}, - {file = "libcst-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d237e9164a43caa7d6765ee560412264484e7620c546a2ee10a8d01bd56884e0"}, - {file = "libcst-1.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:440887e5f82efb299f2e98d4bfa5663851a878cfc0efed652ab8c50205191436"}, - {file = "libcst-1.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:ae7f4e71d714f256b5f2ff98b5a9effba0f9dff4d779d8f35d7eb157bef78f59"}, - {file = "libcst-1.0.1.tar.gz", hash = "sha256:37187337f979ba426d8bfefc08008c3c1b09b9e9f9387050804ed2da88107570"}, + {file = "libcst-1.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:63f75656fd733dc20354c46253fde3cf155613e37643c3eaf6f8818e95b7a3d1"}, + {file = "libcst-1.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8ae11eb1ea55a16dc0cdc61b41b29ac347da70fec14cc4381248e141ee2fbe6c"}, + {file = "libcst-1.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:4bc745d0c06420fe2644c28d6ddccea9474fb68a2135904043676deb4fa1e6bc"}, + {file = "libcst-1.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8c1f2da45f1c45634090fd8672c15e0159fdc46853336686959b2d093b6e10fa"}, + {file = "libcst-1.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:003e5e83a12eed23542c4ea20fdc8de830887cc03662432bb36f84f8c4841b81"}, + {file = "libcst-1.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:3ebbb9732ae3cc4ae7a0e97890bed0a57c11d6df28790c2b9c869f7da653c7c7"}, + {file = "libcst-1.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:d68c34e3038d3d1d6324eb47744cbf13f2c65e1214cf49db6ff2a6603c1cd838"}, + {file = "libcst-1.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9dffa1795c2804d183efb01c0f1efd20a7831db6a21a0311edf90b4100d67436"}, + {file = "libcst-1.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cc9b6ac36d7ec9db2f053014ea488086ca2ed9c322be104fbe2c71ca759da4bb"}, + {file = "libcst-1.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:78b7a38ec4c1c009ac39027d51558b52851fb9234669ba5ba62283185963a31c"}, + {file = "libcst-1.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:5297a16e575be8173185e936b7765c89a3ca69d4ae217a4af161814a0f9745a7"}, + {file = "libcst-1.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:7ccaf53925f81118aeaadb068a911fac8abaff608817d7343da280616a5ca9c1"}, + {file = "libcst-1.1.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:75816647736f7e09c6120bdbf408456f99b248d6272277eed9a58cf50fb8bc7d"}, + {file = "libcst-1.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:c8f26250f87ca849a7303ed7a4fd6b2c7ac4dec16b7d7e68ca6a476d7c9bfcdb"}, + {file = "libcst-1.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:2d37326bd6f379c64190a28947a586b949de3a76be00176b0732c8ee87d67ebe"}, + {file = "libcst-1.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e3d8cf974cfa2487b28f23f56c4bff90d550ef16505e58b0dca0493d5293784b"}, + {file = "libcst-1.1.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:82d1271403509b0a4ee6ff7917c2d33b5a015f44d1e208abb1da06ba93b2a378"}, + {file = "libcst-1.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:bca1841693941fdd18371824bb19a9702d5784cd347cb8231317dbdc7062c5bc"}, + {file = "libcst-1.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:f36f592e035ef84f312a12b75989dde6a5f6767fe99146cdae6a9ee9aff40dd0"}, + {file = "libcst-1.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:f561c9a84eca18be92f4ad90aa9bd873111efbea995449301719a1a7805dbc5c"}, + {file = "libcst-1.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:97fbc73c87e9040e148881041fd5ffa2a6ebf11f64b4ccb5b52e574b95df1a15"}, + {file = "libcst-1.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:99fdc1929703fd9e7408aed2e03f58701c5280b05c8911753a8d8619f7dfdda5"}, + {file = "libcst-1.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:0bf69cbbab5016d938aac4d3ae70ba9ccb3f90363c588b3b97be434e6ba95403"}, + {file = "libcst-1.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:fe41b33aa73635b1651f64633f429f7aa21f86d2db5748659a99d9b7b1ed2a90"}, + {file = "libcst-1.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:73c086705ed34dbad16c62c9adca4249a556c1b022993d511da70ea85feaf669"}, + {file = "libcst-1.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:3a07ecfabbbb8b93209f952a365549e65e658831e9231649f4f4e4263cad24b1"}, + {file = "libcst-1.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c653d9121d6572d8b7f8abf20f88b0a41aab77ff5a6a36e5a0ec0f19af0072e8"}, + {file = "libcst-1.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5f1cd308a4c2f71d5e4eec6ee693819933a03b78edb2e4cc5e3ad1afd5fb3f07"}, + {file = "libcst-1.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:8afb6101b8b3c86c5f9cec6b90ab4da16c3c236fe7396f88e8b93542bb341f7c"}, + {file = "libcst-1.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:d22d1abfe49aa60fc61fa867e10875a9b3024ba5a801112f4d7ba42d8d53242e"}, + {file = "libcst-1.1.0.tar.gz", hash = "sha256:0acbacb9a170455701845b7e940e2d7b9519db35a86768d86330a0b0deae1086"}, ] [package.dependencies] @@ -276,7 +277,7 @@ typing-extensions = ">=3.7.4.2" typing-inspect = ">=0.4.0" [package.extras] -dev = ["Sphinx (>=5.1.1)", "black (==23.3.0)", "build (>=0.10.0)", "coverage (>=4.5.4)", "fixit (==0.1.1)", "flake8 (>=3.7.8,<5)", "hypothesis (>=4.36.0)", "hypothesmith (>=0.0.4)", "jinja2 (==3.1.2)", "jupyter (>=1.0.0)", "maturin (>=0.8.3,<0.16)", "nbsphinx (>=0.4.2)", "prompt-toolkit (>=2.0.9)", "pyre-check (==0.9.10)", "setuptools-rust (>=1.5.2)", "setuptools-scm (>=6.0.1)", "slotscheck (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "ufmt (==2.1.0)", "usort (==1.0.7)"] +dev = ["Sphinx (>=5.1.1)", "black (==23.9.1)", "build (>=0.10.0)", "coverage (>=4.5.4)", "fixit (==2.0.0.post1)", "flake8 (>=3.7.8,<5)", "hypothesis (>=4.36.0)", "hypothesmith (>=0.0.4)", "jinja2 (==3.1.2)", "jupyter (>=1.0.0)", "maturin (>=0.8.3,<0.16)", "nbsphinx (>=0.4.2)", "prompt-toolkit (>=2.0.9)", "pyre-check (==0.9.18)", "setuptools-rust (>=1.5.2)", "setuptools-scm (>=6.0.1)", "slotscheck (>=0.7.1)", "sphinx-rtd-theme (>=0.4.3)", "ufmt (==2.2.0)", "usort (==1.0.7)"] [[package]] name = "markupsafe" @@ -411,13 +412,13 @@ requests = "*" [[package]] name = "pycnite" -version = "2023.9.18" +version = "2023.10.5" description = "Python bytecode utilities" optional = false python-versions = ">=3.8" files = [ - {file = "pycnite-2023.9.18-py3-none-any.whl", hash = "sha256:26cc0cdda12ca6c6879a5d7e0dd332720f7f9fc9e6a74c02d00dcb7d71bdfa9f"}, - {file = "pycnite-2023.9.18.tar.gz", hash = "sha256:c353d369b15f5d635d10d32d200ea75d73f1ca54395be9c2e327c09cfeb27b68"}, + {file = "pycnite-2023.10.5-py3-none-any.whl", hash = "sha256:37cf270afe3391f01bb9ce926c948007f7eb0ca58428ca7142249217302841e5"}, + {file = "pycnite-2023.10.5.tar.gz", hash = "sha256:c3df5784632e413569bcbab749fe2ec81f74a5c4a94fd19be594892079e6f577"}, ] [[package]] @@ -558,6 +559,23 @@ files = [ typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" [[package]] +name = "pydocstyle" +version = "6.3.0" +description = "Python docstring style checker" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pydocstyle-6.3.0-py3-none-any.whl", hash = "sha256:118762d452a49d6b05e194ef344a55822987a462831ade91ec5c06fd2169d019"}, + {file = "pydocstyle-6.3.0.tar.gz", hash = "sha256:7ce43f0c0ac87b07494eb9c0b462c0b73e6ff276807f204d6b53edc72b7e44e1"}, +] + +[package.dependencies] +snowballstemmer = ">=2.2.0" + +[package.extras] +toml = ["tomli (>=1.2.3)"] + +[[package]] name = "pydot" version = "1.4.2" description = "Python interface to Graphviz's Dot" @@ -601,21 +619,21 @@ cli = ["click (>=5.0)"] [[package]] name = "pytype" -version = "2023.9.27" +version = "2023.10.5" description = "Python type inferencer" optional = false python-versions = ">=3.8" files = [ - {file = "pytype-2023.9.27-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:3027ab37496776ec8ec10e7d69e7f20a964bc185e0b894f6511def4c50db068e"}, - {file = "pytype-2023.9.27-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c0fb5800e946f714bc117352d4010ff08d6fcb4d6423f2c5bc80e0b4c9fea641"}, - {file = "pytype-2023.9.27-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:29cf0d7c6401c6e9ed71716ffff884cd016b88007813ef1a922153b93d71103f"}, - {file = "pytype-2023.9.27-cp38-cp38-macosx_11_0_x86_64.whl", hash = "sha256:7d460890f4e0aa1c3e3f440e66c00b7d772aba85ff7f3e8ba4b5e0b7bc352a67"}, - {file = "pytype-2023.9.27-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:25c217b64e6502a9e40d68ae58d00f7d645100f0c8fbe3df840dbde21533cba5"}, - {file = "pytype-2023.9.27-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:768b924d54da5add190431037cbe54626c99bd377df8d05fea852eb6bec33be7"}, - {file = "pytype-2023.9.27-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:2e38df1f0b15a28ba3abb3e0c9a3df85732985ccd1d0155454f0ae44891874fc"}, - {file = "pytype-2023.9.27-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1a2ded4ac6ee7dbc073b062c5a6a7dfb71a36e5c82786d47e111c7fe2d3add45"}, - {file = "pytype-2023.9.27-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e7b5c2753b2c5f0714c8ab03982a5383f677494e246293665015839e5b0daec2"}, - {file = "pytype-2023.9.27.tar.gz", hash = "sha256:61ad4801f7f1f810bcd1dc83870c614606078e9c281135438cd03807dc380a6b"}, + {file = "pytype-2023.10.5-cp310-cp310-macosx_11_0_x86_64.whl", hash = "sha256:6e2a056290985b1c7522da1538dedd3f74a2cd079a901996c9dfdf5de3749825"}, + {file = "pytype-2023.10.5-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d2edfcc738798eae4e96d3fa5426278fa05869e94b1adbc4409bf7c7b4c12a5"}, + {file = "pytype-2023.10.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:2eacd18c52ea508c1d09e4bec15676a2350051b5e15baf032f1b80c4f8695550"}, + {file = "pytype-2023.10.5-cp38-cp38-macosx_11_0_x86_64.whl", hash = "sha256:947a186947c308cf473cf1c17ba7aeedd57e1721d5ede401854d8d48a273ef6b"}, + {file = "pytype-2023.10.5-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:89515d7c32343b6e4ee6811b003d6d368efee3b019d06eeb8f777f595b65b488"}, + {file = "pytype-2023.10.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d19404ee2ef6db0cd5bc154d007e88249e4dd43c3d91d1c518f50ea7b9d5baaa"}, + {file = "pytype-2023.10.5-cp39-cp39-macosx_11_0_x86_64.whl", hash = "sha256:0539a7fa575cc1098bb449fb191be96728121940c7ae0079fe0dcfdf148ac3b9"}, + {file = "pytype-2023.10.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:951055eb8d61d431ff49b3b23e0dee6bf625371edf1d00712bd5475c53bdf8fc"}, + {file = "pytype-2023.10.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6b629c3197a3fe5e06cc1cd0965ab316ece874f0064a16f6b993b05556716264"}, + {file = "pytype-2023.10.5.tar.gz", hash = "sha256:d465ac20807727c6a430bcf72ffc2ed2b6f37c220d3965d8d466042fe25bc1ca"}, ] [package.dependencies] @@ -702,6 +720,17 @@ socks = ["PySocks (>=1.5.6,!=1.5.7)"] use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] +name = "snowballstemmer" +version = "2.2.0" +description = "This package provides 29 stemmers for 28 languages generated from Snowball algorithms." +optional = false +python-versions = "*" +files = [ + {file = "snowballstemmer-2.2.0-py2.py3-none-any.whl", hash = "sha256:c8e1716e83cc398ae16824e5572ae04e0d9fc2c6b985fb0f900f5f0c96ecba1a"}, + {file = "snowballstemmer-2.2.0.tar.gz", hash = "sha256:09b16deb8547d3412ad7b590689584cd0fe25ec8db3be37788be3810cbf19cb1"}, +] + +[[package]] name = "tabulate" version = "0.9.0" description = "Pretty-print tabular data" @@ -754,13 +783,13 @@ typing-extensions = ">=3.7.4" [[package]] name = "urllib3" -version = "2.0.5" +version = "2.0.6" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.7" files = [ - {file = "urllib3-2.0.5-py3-none-any.whl", hash = "sha256:ef16afa8ba34a1f989db38e1dbbe0c302e4289a47856990d0682e374563ce35e"}, - {file = "urllib3-2.0.5.tar.gz", hash = "sha256:13abf37382ea2ce6fb744d4dad67838eec857c9f4f57009891805e0b5e123594"}, + {file = "urllib3-2.0.6-py3-none-any.whl", hash = "sha256:7a7c7003b000adf9e7ca2a377c9688bbc54ed41b985789ed576570342a375cd2"}, + {file = "urllib3-2.0.6.tar.gz", hash = "sha256:b19e1a85d206b56d7df1d5e683df4a7725252a964e3993648dd0fb5a1c157564"}, ] [package.extras] @@ -772,4 +801,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "71d329202935e4a3c2a302a6bd4ce6d91f74f1fcbb28605d360753c5888d076a" +content-hash = "0569366cc46e30e59708e5aba3b17fe878b3f37b1aaa68900c88f08ed04da98b" diff --git a/pyproject.toml b/pyproject.toml index 8b25550..8af13f3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -15,7 +15,11 @@ pydantic = "^2.4.2" [tool.poetry.group.dev.dependencies] pytype = "^2023.9.27" +pydocstyle = "^6.3.0" [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" + +[tool.pydocstyle] +ignore = "D107,D200,D203,D205,D211,D212,D213,D400,D406,D407,D413,D415" diff --git a/requirements.txt b/requirements.txt index f444b6e..3529f21 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,9 @@ about-time==4.2.1 ; python_version >= "3.10" and python_version < "4" \ alive-progress==3.1.4 ; python_version >= "3.10" and python_version < "4" \ --hash=sha256:74a95d8d0d42bc99d3a3725dbd06ebb852245f1b64e301a7c375b92b22663f7b \ --hash=sha256:c80ad87ce9c1054b01135a87fae69ecebbfc2107497ae87cbe6aec7e534903db -annotated-types==0.5.0 ; python_version >= "3.10" and python_version < "4.0" \ - --hash=sha256:47cdc3490d9ac1506ce92c7aaa76c579dc3509ff11e098fc867e5130ab7be802 \ - --hash=sha256:58da39888f92c276ad970249761ebea80ba544b77acddaa1a4d6cf78287d45fd +annotated-types==0.6.0 ; python_version >= "3.10" and python_version < "4.0" \ + --hash=sha256:0641064de18ba7a25dee8f96403ebc39113d0cb953a01429249d5c7564666a43 \ + --hash=sha256:563339e807e53ffd9c267e99fc6d9ea23eb8443c08f112651963e24e22f84a5d certifi==2023.7.22 ; python_version >= "3.10" and python_version < "4.0" \ --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 @@ -231,6 +231,6 @@ requests==2.31.0 ; python_version >= "3.10" and python_version < "4.0" \ typing-extensions==4.8.0 ; python_version >= "3.10" and python_version < "4.0" \ --hash=sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0 \ --hash=sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef -urllib3==2.0.5 ; python_version >= "3.10" and python_version < "4.0" \ - --hash=sha256:13abf37382ea2ce6fb744d4dad67838eec857c9f4f57009891805e0b5e123594 \ - --hash=sha256:ef16afa8ba34a1f989db38e1dbbe0c302e4289a47856990d0682e374563ce35e +urllib3==2.0.6 ; python_version >= "3.10" and python_version < "4.0" \ + --hash=sha256:7a7c7003b000adf9e7ca2a377c9688bbc54ed41b985789ed576570342a375cd2 \ + --hash=sha256:b19e1a85d206b56d7df1d5e683df4a7725252a964e3993648dd0fb5a1c157564 diff --git a/src/lib/szurubooru.py b/src/lib/szurubooru.py index 38c6265..2484691 100644 --- a/src/lib/szurubooru.py +++ b/src/lib/szurubooru.py @@ -55,7 +55,7 @@ class SzurubooruException(Exception): @staticmethod def response_is_exception(res: r.Response) -> bool: - """Checks if the Szurubooru REST API response is an error or not. + """Check if the Szurubooru REST API response is an error or not. Args: res (r.Response): the Response of the request from the requests module. @@ -63,12 +63,11 @@ class SzurubooruException(Exception): Returns: bool: True if response is an error and False if it is not. """ - return res.status_code != 200 @staticmethod def map_exception(res: r.Response) -> Exception: - """Generates an exception for an error response from the Szurubooru REST API. + """Generate an exception for an error response from the Szurubooru REST API. Args: res (r.Response): the Response from the Szurubooru REST API that should be @@ -83,7 +82,6 @@ class SzurubooruException(Exception): Returns: Exception: Returns a more specific exception. """ - content: dict[str, str] = json.loads(res.content) name: str = content["name"] title: str = content["title"] @@ -180,175 +178,175 @@ class SzurubooruException(Exception): raise LookupError(f'Unknown SzurubooruException: "{name}"') -class MissingRequiredFileError(SzurubooruException): +class MissingRequiredFileError(SzurubooruException): # noqa: D101 pass -class MissingRequiredParameterError(SzurubooruException): +class MissingRequiredParameterError(SzurubooruException): # noqa: D101 pass -class InvalidParameterError(SzurubooruException): +class InvalidParameterError(SzurubooruException): # noqa: D101 pass -class IntegrityError(SzurubooruException): +class IntegrityError(SzurubooruException): # noqa: D101 pass -class SearchError(SzurubooruException): +class SearchError(SzurubooruException): # noqa: D101 pass -class AuthError(SzurubooruException): +class AuthError(SzurubooruException): # noqa: D101 pass -class PostNotFoundError(SzurubooruException): +class PostNotFoundError(SzurubooruException): # noqa: D101 pass -class PostAlreadyFeaturedError(SzurubooruException): +class PostAlreadyFeaturedError(SzurubooruException): # noqa: D101 pass -class PostAlreadyUploadedError(SzurubooruException): +class PostAlreadyUploadedError(SzurubooruException): # noqa: D101 pass -class InvalidPostIdError(SzurubooruException): +class InvalidPostIdError(SzurubooruException): # noqa: D101 pass -class InvalidPostSafetyError(SzurubooruException): +class InvalidPostSafetyError(SzurubooruException): # noqa: D101 pass -class InvalidPostSourceError(SzurubooruException): +class InvalidPostSourceError(SzurubooruException): # noqa: D101 pass -class InvalidPostContentError(SzurubooruException): +class InvalidPostContentError(SzurubooruException): # noqa: D101 pass -class InvalidPostRelationError(SzurubooruException): +class InvalidPostRelationError(SzurubooruException): # noqa: D101 pass -class InvalidPostNoteError(SzurubooruException): +class InvalidPostNoteError(SzurubooruException): # noqa: D101 pass -class InvalidPostFlagError(SzurubooruException): +class InvalidPostFlagError(SzurubooruException): # noqa: D101 pass -class InvalidFavoriteTargetError(SzurubooruException): +class InvalidFavoriteTargetError(SzurubooruException): # noqa: D101 pass -class InvalidCommentIdError(SzurubooruException): +class InvalidCommentIdError(SzurubooruException): # noqa: D101 pass -class CommentNotFoundError(SzurubooruException): +class CommentNotFoundError(SzurubooruException): # noqa: D101 pass -class EmptyCommentTextError(SzurubooruException): +class EmptyCommentTextError(SzurubooruException): # noqa: D101 pass -class InvalidScoreTargetError(SzurubooruException): +class InvalidScoreTargetError(SzurubooruException): # noqa: D101 pass -class InvalidScoreValueError(SzurubooruException): +class InvalidScoreValueError(SzurubooruException): # noqa: D101 pass -class TagCategoryNotFoundError(SzurubooruException): +class TagCategoryNotFoundError(SzurubooruException): # noqa: D101 pass -class TagCategoryAlreadyExistsError(SzurubooruException): +class TagCategoryAlreadyExistsError(SzurubooruException): # noqa: D101 pass -class TagCategoryIsInUseError(SzurubooruException): +class TagCategoryIsInUseError(SzurubooruException): # noqa: D101 pass -class InvalidTagCategoryNameError(SzurubooruException): +class InvalidTagCategoryNameError(SzurubooruException): # noqa: D101 pass -class InvalidTagCategoryColorError(SzurubooruException): +class InvalidTagCategoryColorError(SzurubooruException): # noqa: D101 pass -class TagNotFoundError(SzurubooruException): +class TagNotFoundError(SzurubooruException): # noqa: D101 pass -class TagAlreadyExistsError(SzurubooruException): +class TagAlreadyExistsError(SzurubooruException): # noqa: D101 pass -class TagIsInUseError(SzurubooruException): +class TagIsInUseError(SzurubooruException): # noqa: D101 pass -class InvalidTagNameError(SzurubooruException): +class InvalidTagNameError(SzurubooruException): # noqa: D101 pass -class InvalidTagRelationError(SzurubooruException): +class InvalidTagRelationError(SzurubooruException): # noqa: D101 pass -class InvalidTagCategoryError(SzurubooruException): +class InvalidTagCategoryError(SzurubooruException): # noqa: D101 pass -class InvalidTagDescriptionError(SzurubooruException): +class InvalidTagDescriptionError(SzurubooruException): # noqa: D101 pass -class UserNotFoundError(SzurubooruException): +class UserNotFoundError(SzurubooruException): # noqa: D101 pass -class UserAlreadyExistsError(SzurubooruException): +class UserAlreadyExistsError(SzurubooruException): # noqa: D101 pass -class InvalidUserNameError(SzurubooruException): +class InvalidUserNameError(SzurubooruException): # noqa: D101 pass -class InvalidEmailError(SzurubooruException): +class InvalidEmailError(SzurubooruException): # noqa: D101 pass -class InvalidPasswordError(SzurubooruException): +class InvalidPasswordError(SzurubooruException): # noqa: D101 pass -class InvalidRankError(SzurubooruException): +class InvalidRankError(SzurubooruException): # noqa: D101 pass -class InvalidAvatarError(SzurubooruException): +class InvalidAvatarError(SzurubooruException): # noqa: D101 pass -class ProcessingError(SzurubooruException): +class ProcessingError(SzurubooruException): # noqa: D101 pass -class ValidationError(SzurubooruException): +class ValidationError(SzurubooruException): # noqa: D101 pass @@ -447,7 +445,7 @@ class Szurubooru: ) def __map_tag_resource_response(self, res: r.Response, name: str = "") -> Tag: - """Maps the requests response from the Szurubooru REST API to the Tag dataclass. + """Map the requests response from the Szurubooru REST API to the Tag dataclass. This function is similar to __map_tag_resource and calls it internally. Instead of receiving a dictionary if the Szurubooru Tag it operates on the @@ -486,11 +484,10 @@ class Szurubooru: -1. The name will be the first name returned by the Szurubooru REST API or the name that was passed to the function as an optional parameter. """ - return self.__map_tag_resource(json.loads(res.content), name) def __map_tag_resource(self, c: dict, name: str = "") -> Tag: - """Maps the dict from the Szurubooru REST API to the Tag dataclass. + """Map the dict from the Szurubooru REST API to the Tag dataclass. This function is similar to __map_tag_resource_response and is called by it. Instead of receiving a requests Response it operates on the dictionary of the @@ -526,7 +523,6 @@ class Szurubooru: -1. The name will be the first name returned by the Szurubooru REST API or the name that was passed to the function as an optional parameter. """ - return Tag( name=name if name != "" else c["names"][0], version=c.get("version", -1), @@ -537,7 +533,7 @@ class Szurubooru: ) def tag_exists(self, name: str) -> bool: - """Checks if the tag exists on Szurubooru. + """Check if the tag exists on Szurubooru. Args: name (str): Name of the tag. @@ -546,7 +542,6 @@ class Szurubooru: bool: True if tag already exists. False if there was no matching tag on Szurubooru. """ - try: res = self.__get(path=f"/api/tag/{quote(name)}") except TagNotFoundError: @@ -556,16 +551,15 @@ class Szurubooru: return res.status_code == 200 def tag_len(self) -> int: - """Checks how many tags there are on the Szurubooru instance. + """Check how many tags there are on the Szurubooru instance. Returns: int: The number of tags that exist on the Szurubooru instance """ - return json.loads(self.__get(path="/api/tags").content)["total"] def tag_list(self, limit: int = 100, offset: int = 0, query: str = "") -> List[Tag]: - """Lists tags on the Szurubooru instance. + """List tags on the Szurubooru instance. Args: limit (int, optional): Limits the amount of tags displayed on one page. @@ -587,13 +581,12 @@ class Szurubooru: Returns: List[Tag]: List of Tag objects in the current page. """ - path = f"/api/tags?offset={offset}&limit={limit}&query={quote(query)}" results = json.loads(self.__get(path=path).content)["results"] return list(map(self.__map_tag_resource, results)) def tag_list_all(self, query: str = "") -> List[Tag]: - """Lists every available Tag (matching the query) on the Szurubooru instance. + """List every available Tag (matching the query) on the Szurubooru instance. WARNING: This method calls the Szurubooru REST API multiple times depending on how many tags there are. It can take a while and can put significant load on the @@ -613,7 +606,6 @@ class Szurubooru: List[Tag]: List of all Tag objects matching the query on the Szurubooru instance. """ - tags = [] for i in range(0, math.ceil(self.tag_len() / 100)): tags.extend(self.tag_list(offset=100 * i, limit=100, query=query)) @@ -631,7 +623,6 @@ class Szurubooru: Returns: Tag: Tag object of the requested tag. """ - res = self.__get(path=f"/api/tag/{quote(name)}") return self.__map_tag_resource_response(res, name=name) @@ -646,7 +637,6 @@ class Szurubooru: representing the created tag as it was created on the Szurubooru instance. """ - res = self.__post( path="/api/tags", params={ @@ -671,7 +661,6 @@ class Szurubooru: representing the updated version of the tag as it is now on the Szurubooru instance. """ - res = self.__put( path=f"/api/tag/{quote(tag.name)}", params={ @@ -685,7 +674,7 @@ class Szurubooru: return self.__map_tag_resource_response(res, name=tag.name) def tag_delete(self, tag: Tag) -> None: - """Deletes the given tag on the Szurubooru instance. + """Delete the given tag on the Szurubooru instance. Args: tag (Tag): Tag dataclass of the tag that should be reledte. Needs to contain @@ -697,7 +686,7 @@ class Szurubooru: return def tag_merge(self, tag_to_merge: Tag, tag_to_merge_into: Tag) -> Tag: - """Removes tag_to_merge and merges all uses into tag_to_merge_into. + """Remove tag_to_merge and merges all uses into tag_to_merge_into. Removes source tag and merges all of its usages, suggestions and implications to the target tag. Other tag properties such as category and aliases do not get @@ -715,7 +704,6 @@ class Szurubooru: Tag: Resulting Tag dataclass that was returned by the Szurubooru REST API representing the new (merged) tag on the Szurubooru instance. """ - res = self.__post( path="/api/tag-merge", params={ @@ -728,7 +716,7 @@ class Szurubooru: return self.__map_tag_resource_response(res, name=tag_to_merge_into.name) def tag_list_siblings(self, tag: Tag) -> List[dict[str, int]]: - """Lists siblings of the given Tag + """List siblings of the given Tag Lists siblings of given tag, e.g. tags that were used in the same posts as the given tag. `occurrences` field signifies how many times a given sibling appears @@ -743,7 +731,6 @@ class Szurubooru: name as the key and the number of occurrences as the value. """ - res = self.__get(path=f"/api/tag-siblings/{tag.name}") results = json.loads(res.content)["results"] return list(map(lambda a: {a["tag"]["names"][0]: a["occurrences"]}, results)) |