From 0c94c10d4e2327b845b5daa3f325be8d4879f137 Mon Sep 17 00:00:00 2001 From: Marion Deveaud Date: Thu, 4 Apr 2024 19:38:25 +0200 Subject: [PATCH] chore(lint): replace flake8, black and isort by ruff --- .flake8 | 4 - .github/workflows/staticchecks.yml | 8 +- fossology/__init__.py | 1 - fossology/obj.py | 24 ----- poetry.lock | 151 ++++++----------------------- pyproject.toml | 13 +-- tests/conftest.py | 2 - 7 files changed, 32 insertions(+), 171 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 53fd3ef..0000000 --- a/.flake8 +++ /dev/null @@ -1,4 +0,0 @@ -[flake8] -exclude = .git,__pycache__,docs/source/conf.py,old,build,dist,.venv/ -max-complexity = 10 -ignore = E501, E203, E231, E701, C901 diff --git a/.github/workflows/staticchecks.yml b/.github/workflows/staticchecks.yml index ae695c7..2f4482d 100644 --- a/.github/workflows/staticchecks.yml +++ b/.github/workflows/staticchecks.yml @@ -28,11 +28,7 @@ jobs: python -m pip install --upgrade pip pip install poetry poetry install --with=dev - - name: Check format with black - run: poetry run poe format - - name: Lint with flake8 - run: poetry run poe style - - name: Sort imports with isort - run: poetry run poe imports + - name: Lint using ruff + run: poetry run ruff check - name: Check types with mypy run: poetry run poe types diff --git a/fossology/__init__.py b/fossology/__init__.py index 28d2f91..60bbdf4 100644 --- a/fossology/__init__.py +++ b/fossology/__init__.py @@ -106,7 +106,6 @@ def fossology_token( class Fossology( Folders, Groups, Items, LicenseEndpoint, Uploads, Jobs, Report, Users, Search ): - """Main Fossology API class Authentication against a running Fossology instance is performed using an API token. diff --git a/fossology/obj.py b/fossology/obj.py index 99f7d8f..c350f52 100644 --- a/fossology/obj.py +++ b/fossology/obj.py @@ -9,7 +9,6 @@ class Agents(object): - """FOSSology agents. Represents the agents currently configured for a given user. @@ -98,7 +97,6 @@ def to_json(self): class User(object): - """FOSSology user. Represents the user currently authenticated against the FOSSology server. @@ -161,7 +159,6 @@ def from_json(cls, json_dict): class UserGroupMember(object): - """FOSSology group member. Represents a member of a group. @@ -193,7 +190,6 @@ def from_json(cls, json_dict): class Folder(object): - """FOSSology folder. Represents a FOSSology folder. @@ -229,7 +225,6 @@ def from_json(cls, json_dict): class Findings(object): - """FOSSology license findings. Represents FOSSology license findings. @@ -268,7 +263,6 @@ def from_json(cls, json_dict): class Group(object): - """FOSSology group. Represents a FOSSology group. @@ -349,7 +343,6 @@ def from_json(cls, json_dict): class License(object): - """FOSSology license. Represents a FOSSology license. @@ -417,7 +410,6 @@ def to_json(self) -> str: class Obligation(object): - """FOSSology license obligation. Represents a FOSSology license obligation. @@ -456,7 +448,6 @@ def from_json(cls, json_dict): class Hash(object): - """FOSSology hash. Represents a FOSSology file hash values. @@ -496,7 +487,6 @@ def from_json(cls, json_dict): class File(object): - """FOSSology file response from filesearch. Represents a FOSSology filesearch response. @@ -531,7 +521,6 @@ def from_json(cls, json_dict): class FileInfo(object): - """FOSSology file info response. Represents a FOSSology file info response. @@ -582,7 +571,6 @@ def from_json(cls, json_dict): class Upload(object): - """FOSSology upload. Represents a FOSSology upload. @@ -655,7 +643,6 @@ def from_json(cls, json_dict): class UploadCopyrights(object): - """Copyright findings in a FOSSology upload Represents copyright matches of a FOSSology upload. @@ -689,7 +676,6 @@ def from_json(cls, json_dict): class UploadLicenses(object): - """FOSSology upload licenses. Represents licenses and copyright matches of a FOSSology upload. @@ -721,7 +707,6 @@ def from_json(cls, json_dict): class Summary(object): - """FOSSology upload summary. Represents a FOSSology upload summary. @@ -792,7 +777,6 @@ def from_json(cls, json_dict): class Job(object): - """FOSSology job. Represents a FOSSology job. @@ -842,7 +826,6 @@ def from_json(cls, json_dict): class ApiLicense(object): - """FOSSology API License. :param name: name of the API license @@ -864,7 +847,6 @@ def from_json(cls, json_dict): class FossologyServer(object): - """FOSSology server info. :param version: version of the FOSSology server (e.g. 4.0.0) @@ -895,7 +877,6 @@ def from_json(cls, json_dict): class ApiInfo(object): - """FOSSology API info. Represents the info endpoint of FOSSology API. @@ -946,7 +927,6 @@ def from_json(cls, json_dict): class Status(object): - """FOSSology server status Represent the status of FOSSology sub-systems @@ -964,7 +944,6 @@ def from_json(cls, json_dict): class HealthInfo(object): - """FOSSology server health info. Represents the health endpoint of FOSSology API. @@ -992,7 +971,6 @@ def from_json(cls, json_dict): class SearchResult(object): - """Search result. Represents a search response from FOSSology API. @@ -1022,7 +1000,6 @@ def from_json(cls, json_dict): class GetClearingHistory(object): - """Clearing history. Represents the clearing history of a specified item. @@ -1070,7 +1047,6 @@ def from_json(cls, json_dict): class GetBulkHistory(object): - """Bulk history. Represents the bulk history of a specified item. diff --git a/poetry.lock b/poetry.lock index bc07888..096386f 100644 --- a/poetry.lock +++ b/poetry.lock @@ -36,40 +36,6 @@ files = [ [package.extras] dev = ["freezegun (>=1.0,<2.0)", "pytest (>=6.0)", "pytest-cov"] -[[package]] -name = "black" -version = "22.12.0" -description = "The uncompromising code formatter." -optional = false -python-versions = ">=3.7" -files = [ - {file = "black-22.12.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9eedd20838bd5d75b80c9f5487dbcb06836a43833a37846cf1d8c1cc01cef59d"}, - {file = "black-22.12.0-cp310-cp310-win_amd64.whl", hash = "sha256:159a46a4947f73387b4d83e87ea006dbb2337eab6c879620a3ba52699b1f4351"}, - {file = "black-22.12.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d30b212bffeb1e252b31dd269dfae69dd17e06d92b87ad26e23890f3efea366f"}, - {file = "black-22.12.0-cp311-cp311-win_amd64.whl", hash = "sha256:7412e75863aa5c5411886804678b7d083c7c28421210180d67dfd8cf1221e1f4"}, - {file = "black-22.12.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c116eed0efb9ff870ded8b62fe9f28dd61ef6e9ddd28d83d7d264a38417dcee2"}, - {file = "black-22.12.0-cp37-cp37m-win_amd64.whl", hash = "sha256:1f58cbe16dfe8c12b7434e50ff889fa479072096d79f0a7f25e4ab8e94cd8350"}, - {file = "black-22.12.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:77d86c9f3db9b1bf6761244bc0b3572a546f5fe37917a044e02f3166d5aafa7d"}, - {file = "black-22.12.0-cp38-cp38-win_amd64.whl", hash = "sha256:82d9fe8fee3401e02e79767016b4907820a7dc28d70d137eb397b92ef3cc5bfc"}, - {file = "black-22.12.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:101c69b23df9b44247bd88e1d7e90154336ac4992502d4197bdac35dd7ee3320"}, - {file = "black-22.12.0-cp39-cp39-win_amd64.whl", hash = "sha256:559c7a1ba9a006226f09e4916060982fd27334ae1998e7a38b3f33a37f7a2148"}, - {file = "black-22.12.0-py3-none-any.whl", hash = "sha256:436cc9167dd28040ad90d3b404aec22cedf24a6e4d7de221bec2730ec0c97bcf"}, - {file = "black-22.12.0.tar.gz", hash = "sha256:229351e5a18ca30f447bf724d007f890f97e13af070bb6ad4c0a441cd7596a2f"}, -] - -[package.dependencies] -click = ">=8.0.0" -mypy-extensions = ">=0.4.3" -pathspec = ">=0.9.0" -platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_full_version < \"3.11.0a7\""} - -[package.extras] -colorama = ["colorama (>=0.4.3)"] -d = ["aiohttp (>=3.7.4)"] -jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] -uvloop = ["uvloop (>=0.15.2)"] - [[package]] name = "certifi" version = "2024.2.2" @@ -307,22 +273,6 @@ files = [ [package.extras] test = ["pytest (>=6)"] -[[package]] -name = "flake8" -version = "5.0.4" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.6.1" -files = [ - {file = "flake8-5.0.4-py2.py3-none-any.whl", hash = "sha256:7a1cf6b73744f5806ab95e526f6f0d8c01c66d7bbe349562d22dfca20610b248"}, - {file = "flake8-5.0.4.tar.gz", hash = "sha256:6fbe320aad8d6b95cec8b8e47bc933004678dc63095be98528b7bdd2a9f510db"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.9.0,<2.10.0" -pyflakes = ">=2.5.0,<2.6.0" - [[package]] name = "idna" version = "3.6" @@ -356,20 +306,6 @@ files = [ {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, ] -[[package]] -name = "isort" -version = "5.13.2" -description = "A Python utility / library to sort Python imports." -optional = false -python-versions = ">=3.8.0" -files = [ - {file = "isort-5.13.2-py3-none-any.whl", hash = "sha256:8ca5e72a8d85860d5a3fa69b8745237f2939afe12dbf656afbcb47fe72d947a6"}, - {file = "isort-5.13.2.tar.gz", hash = "sha256:48fdfcb9face5d58a4f6dde2e72a1fb8dcaf8ab26f95ab49fab84c2ddefb0109"}, -] - -[package.extras] -colors = ["colorama (>=0.4.6)"] - [[package]] name = "jinja2" version = "3.1.3" @@ -495,17 +431,6 @@ files = [ {file = "MarkupSafe-2.1.5.tar.gz", hash = "sha256:d283d37a890ba4c1ae73ffadf8046435c76e7bc2247bbb63c00bd1a709c6544b"}, ] -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - [[package]] name = "mdurl" version = "0.1.2" @@ -597,32 +522,6 @@ files = [ {file = "pastel-0.2.1.tar.gz", hash = "sha256:e6581ac04e973cac858828c6202c1e1e81fee1dc7de7683f3e1ffe0bfd8a573d"}, ] -[[package]] -name = "pathspec" -version = "0.12.1" -description = "Utility library for gitignore style pattern matching of file paths." -optional = false -python-versions = ">=3.8" -files = [ - {file = "pathspec-0.12.1-py3-none-any.whl", hash = "sha256:a0d503e138a4c123b27490a4f7beda6a01c6f288df0e4a8b79c7eb0dc7b4cc08"}, - {file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"}, -] - -[[package]] -name = "platformdirs" -version = "4.2.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, - {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] - [[package]] name = "pluggy" version = "1.4.0" @@ -656,17 +555,6 @@ tomli = ">=1.2.2" [package.extras] poetry-plugin = ["poetry (>=1.0,<2.0)"] -[[package]] -name = "pycodestyle" -version = "2.9.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pycodestyle-2.9.1-py2.py3-none-any.whl", hash = "sha256:d1735fc58b418fd7c5f658d28d943854f8a849b01a5d0a1e6f3f3fdd0166804b"}, - {file = "pycodestyle-2.9.1.tar.gz", hash = "sha256:2c9607871d58c76354b697b42f5d57e1ada7d261c261efac224b664affdc5785"}, -] - [[package]] name = "pydantic" version = "2.6.1" @@ -777,17 +665,6 @@ files = [ [package.dependencies] typing-extensions = ">=4.6.0,<4.7.0 || >4.7.0" -[[package]] -name = "pyflakes" -version = "2.5.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.6" -files = [ - {file = "pyflakes-2.5.0-py2.py3-none-any.whl", hash = "sha256:4579f67d887f804e67edb544428f264b7b24f435b263c4614f384135cea553d2"}, - {file = "pyflakes-2.5.0.tar.gz", hash = "sha256:491feb020dca48ccc562a8c0cbe8df07ee13078df59813b83959cbdada312ea3"}, -] - [[package]] name = "pygments" version = "2.17.2" @@ -1005,6 +882,32 @@ toml = ["tomli (>=2.0)"] type-check = ["mypy (>=1.0)", "types-PyYAML (>=6.0.0)", "types-docutils (>=0.18)"] yaml = ["pyyaml (>=6.0.0)"] +[[package]] +name = "ruff" +version = "0.3.5" +description = "An extremely fast Python linter and code formatter, written in Rust." +optional = false +python-versions = ">=3.7" +files = [ + {file = "ruff-0.3.5-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:aef5bd3b89e657007e1be6b16553c8813b221ff6d92c7526b7e0227450981eac"}, + {file = "ruff-0.3.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:89b1e92b3bd9fca249153a97d23f29bed3992cff414b222fcd361d763fc53f12"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5e55771559c89272c3ebab23326dc23e7f813e492052391fe7950c1a5a139d89"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:dabc62195bf54b8a7876add6e789caae0268f34582333cda340497c886111c39"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3a05f3793ba25f194f395578579c546ca5d83e0195f992edc32e5907d142bfa3"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:dfd3504e881082959b4160ab02f7a205f0fadc0a9619cc481982b6837b2fd4c0"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:87258e0d4b04046cf1d6cc1c56fadbf7a880cc3de1f7294938e923234cf9e498"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:712e71283fc7d9f95047ed5f793bc019b0b0a29849b14664a60fd66c23b96da1"}, + {file = "ruff-0.3.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a532a90b4a18d3f722c124c513ffb5e5eaff0cc4f6d3aa4bda38e691b8600c9f"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:122de171a147c76ada00f76df533b54676f6e321e61bd8656ae54be326c10296"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:d80a6b18a6c3b6ed25b71b05eba183f37d9bc8b16ace9e3d700997f00b74660b"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_i686.whl", hash = "sha256:a7b6e63194c68bca8e71f81de30cfa6f58ff70393cf45aab4c20f158227d5936"}, + {file = "ruff-0.3.5-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:a759d33a20c72f2dfa54dae6e85e1225b8e302e8ac655773aff22e542a300985"}, + {file = "ruff-0.3.5-py3-none-win32.whl", hash = "sha256:9d8605aa990045517c911726d21293ef4baa64f87265896e491a05461cae078d"}, + {file = "ruff-0.3.5-py3-none-win_amd64.whl", hash = "sha256:dc56bb16a63c1303bd47563c60482a1512721053d93231cf7e9e1c6954395a0e"}, + {file = "ruff-0.3.5-py3-none-win_arm64.whl", hash = "sha256:faeeae9905446b975dcf6d4499dc93439b131f1443ee264055c5716dd947af55"}, + {file = "ruff-0.3.5.tar.gz", hash = "sha256:a067daaeb1dc2baf9b82a32dae67d154d95212080c80435eb052d95da647763d"}, +] + [[package]] name = "shellingham" version = "1.5.4" @@ -1310,4 +1213,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "aefeca78286450130ed2965d921199534e5412fceb158e0f285fddb0ed61ff3e" +content-hash = "87f06fae637f0127b2046967556902bae8ea5130dbd734c09598d91982724272" diff --git a/pyproject.toml b/pyproject.toml index cf95a89..cadec36 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,9 +18,6 @@ classifiers = [ "Programming Language :: Python :: 3 :: Only", ] -[tool.isort] -profile = "black" - [tool.mypy] exclude = ["tests/"] @@ -36,25 +33,21 @@ poethepoet = "^0.21.1" types-requests = "^2.31.0.2" [tool.poetry.group.dev.dependencies] -flake8 = ">=5.0.4" sphinx = ">=7.1.2" -black = "^22.12.0" coverage = "^6.5.0" codecov = "^2.1.13" -pyflakes = "^2.5.0" pytest = "^7.4.0" responses = "^0.23.3" -isort = "^5.12.0" sphinx-autobuild = "^2021.3.14" rstcheck = "^6.1.2" requests-toolbelt = "^0.9.1" mypy = "^1.4.1" +ruff = "^0.3.5" [tool.poe.tasks] types = { cmd = "mypy ." } -format = { cmd = "black . --check" } -style = { cmd = "flake8 ." } -imports = { cmd = "isort ." } +lint = { cmd = "ruff check" } +format = { cmd = "ruff format" } [tool.poetry.scripts] foss_cli = "fossology.foss_cli:main" diff --git a/tests/conftest.py b/tests/conftest.py index 0c01fff..71342d7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -89,7 +89,6 @@ def foss_schedule_agents() -> Dict: "keyword": True, "monk": True, "mime": True, - "monk": True, "nomos": True, "ojo": True, "package": True, @@ -122,7 +121,6 @@ def foss_user_agents() -> Dict: "mimetype": False, "monk": True, "mime": True, - "monk": True, "nomos": True, "ojo": True, "package": True,