Skip to content

Commit

Permalink
Change: Use ruff instead of pylint
Browse files Browse the repository at this point in the history
Use ruff for linting instead of pylint because it's so much faster.
  • Loading branch information
bjoernricks committed Jul 3, 2023
1 parent fe5a1ac commit a4d0d4d
Show file tree
Hide file tree
Showing 32 changed files with 107 additions and 265 deletions.
250 changes: 37 additions & 213 deletions poetry.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions pontos/changelog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
from .errors import ChangelogBuilderError, ChangelogError
from .main import main

__all__ = [
__all__ = (
"ChangelogError",
"ChangelogBuilderError",
"ChangelogBuilder",
]
"main",
)
1 change: 1 addition & 0 deletions pontos/github/actions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@
"Ref",
"PullRequestState",
"GitHubPullRequestEvent",
"main",
)
2 changes: 1 addition & 1 deletion pontos/github/actions/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


def split_pairs(value: str):
if not "=" in value:
if "=" not in value:
raise ValueError(f"Must contain a 'name=value' pair not '{value}'.")
return tuple(value.split("=", 1))

Expand Down
4 changes: 2 additions & 2 deletions pontos/github/actions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def group(cls, title: str):
@staticmethod
def start_group(title: str):
"""
Start a new folable group
Start a new foldable group
Args:
title: Title of the group
Expand Down Expand Up @@ -196,7 +196,7 @@ def debug(message: str):
These messages are only shown if the secret ACTIONS_STEP_DEBUG is set to true.
See https://docs.github.com/en/actions/monitoring-and-troubleshooting-workflows/enabling-debug-logging#enabling-step-debug-logging
"""
""" # noqa: E501
print(f"::debug::{message}")


Expand Down
2 changes: 1 addition & 1 deletion pontos/github/actions/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def __init__(self, pull_request_data: Dict[str, Any]):

self.draft = data.get("draft")
self.number = data.get("number")
self.labels = [Label(label.get("name")) for label in data.get("labels")] # type: ignore #pylint: disable=line-too-long
self.labels = [Label(label.get("name")) for label in data.get("labels")] # type: ignore #pylint: disable=line-too-long # noqa: E501
self.title = data.get("title")
self.merged = data.get("merged")
self.state = PullRequestState(data.get("state"))
Expand Down
2 changes: 1 addition & 1 deletion pontos/github/api/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_workflow_run_artifacts(
async with GitHubAsyncRESTApi(token) as api:
async for artifact in api.artifacts.get_workflow_run_artifacts("foo/bar", 234):
print(artifact)
"""
""" # noqa: E501
api = f"/repos/{repo}/actions/runs/{run}/artifacts"
return self._get_paged_artifacts(api)

Expand Down
8 changes: 4 additions & 4 deletions pontos/github/api/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def download_release_tarball(
async for content, progress in download:
f.write(content)
print(progress)
"""
""" # noqa: E501
api = f"https://github.com/{repo}/archive/refs/tags/{tag}.tar.gz"
return download_async(self._client.stream(api))

Expand Down Expand Up @@ -206,7 +206,7 @@ def download_release_zip(
async for content, progress in download:
f.write(content)
print(progress)
"""
""" # noqa: E501
api = f"https://github.com/{repo}/archive/refs/tags/{tag}.zip"
return download_async(self._client.stream(api))

Expand Down Expand Up @@ -258,7 +258,7 @@ async def download_asset(name: str, download_cm) -> Path:
)
file_paths = await asyncio.gather(*tasks)
"""
""" # noqa: E501
release = await self.get(repo, tag)
assets_url = release.assets_url
if not assets_url:
Expand Down Expand Up @@ -320,7 +320,7 @@ async def upload_release_assets(
"foo/bar", "1.2.3", files
):
print(f"Uploaded: {uploaded_file}")
"""
""" # noqa: E501
release = await self.get(repo, tag)
asset_url = release.upload_url.replace("{?name,label}", "")

Expand Down
4 changes: 2 additions & 2 deletions pontos/github/api/teams.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ async def create(
async with GitHubAsyncRESTApi(token) as api:
team = await api.teams.create("foo", "devops")
print(team)
"""
""" # noqa: E501
api = f"/orgs/{organization}/teams"
data: Dict[str, Any] = {"name": name}
if description:
Expand Down Expand Up @@ -219,7 +219,7 @@ async def update(
team = await api.teams.update(
"foo", "devops", name="DevSecOps"
)
"""
""" # noqa: E501
api = f"/orgs/{organization}/teams/{team}"
data: Dict[str, Any] = {}
if name:
Expand Down
2 changes: 2 additions & 0 deletions pontos/github/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# ruff: noqa: F403

from pontos.github.models.artifact import *
from pontos.github.models.base import *
from pontos.github.models.branch import *
Expand Down
4 changes: 2 additions & 2 deletions pontos/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ def from_dict(cls, data: Dict[str, Any]):
try:
if isinstance(value, list):
model_field_cls = type_hints.get(name)
value = [cls._get_value(model_field_cls, v) for v in value] # type: ignore # pylint: disable= line-too-long
value = [cls._get_value(model_field_cls, v) for v in value] # type: ignore # pylint: disable=line-too-long # noqa: E501
elif value is not None:
model_field_cls = type_hints.get(name)
value = cls._get_value(model_field_cls, value) # type: ignore # pylint: disable= line-too-long
value = cls._get_value(model_field_cls, value) # type: ignore # pylint: disable=line-too-long # noqa: E501
except TypeError as e:
raise ModelError(
f"Error while creating {cls.__name__}. Could not set value "
Expand Down
2 changes: 1 addition & 1 deletion pontos/nvd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from .api import *
from .api import NVDApi, convert_camel_case, format_date, now

__all__ = (
"convert_camel_case",
Expand Down
2 changes: 1 addition & 1 deletion pontos/nvd/cve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from argparse import ArgumentParser, Namespace
from typing import Callable

from pontos.nvd.cve.api import *
from pontos.nvd.cve.api import CVEApi

__all__ = ("CVEApi",)

Expand Down
1 change: 1 addition & 0 deletions pontos/release/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
"SignCommand",
"SignatureError",
"SignReturnValue",
"main",
)
2 changes: 1 addition & 1 deletion pontos/release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def main(
term.print(f"Output was: {error}")
sys.exit(1)
except subprocess.CalledProcessError as e:
if not "--passphrase" in e.cmd:
if "--passphrase" not in e.cmd:
term.error(f'Could not run command "{e.cmd}".')
else:
term.error("Headless signing failed.")
Expand Down
4 changes: 2 additions & 2 deletions pontos/release/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ async def run(
)

# pylint: disable=line-too-long
async for name, download_cm in github.releases.download_release_assets(
async for name, download_cm in github.releases.download_release_assets( # noqa: E501
repo,
git_version,
):
Expand Down Expand Up @@ -350,7 +350,7 @@ async def run(

try:
# pylint: disable=line-too-long
async for uploaded_file in github.releases.upload_release_assets(
async for uploaded_file in github.releases.upload_release_assets( # noqa: E501
repo, git_version, upload_files
):
self.terminal.ok(f"Uploaded: {uploaded_file}")
Expand Down
1 change: 1 addition & 0 deletions pontos/version/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
"Version",
"VersionCalculator",
"VersionUpdate",
"main",
)
10 changes: 5 additions & 5 deletions pontos/version/commands/_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _get_version_from_pyproject_toml(self) -> Version:
if (
"tool" in self.pyproject_toml
and "poetry" in self.pyproject_toml["tool"] # type: ignore
and "version" in self.pyproject_toml["tool"]["poetry"] # type: ignore # pylint: disable=line-too-long
and "version" in self.pyproject_toml["tool"]["poetry"] # type: ignore # pylint: disable=line-too-long # noqa: E501
):
return PEP440VersioningScheme.parse_version(
self.pyproject_toml["tool"]["poetry"]["version"]
Expand Down Expand Up @@ -84,10 +84,10 @@ def _update_pyproject_version(

if "poetry" not in pyproject_toml["tool"]: # type: ignore
poetry_table = tomlkit.table()
# pylint: disable=line-too-long, no-member # ignore pylint (2.13.9) error: pontos/version/python.py:128:12: E1101: Instance of 'OutOfOrderTableProxy' has no 'add' member (no-member)
# pylint: disable=line-too-long, no-member # ignore pylint (2.13.9) error: pontos/version/python.py:128:12: E1101: Instance of 'OutOfOrderTableProxy' has no 'add' member (no-member) # noqa: E501
pyproject_toml["tool"].add("poetry", poetry_table) # type: ignore

pyproject_toml["tool"]["poetry"]["version"] = str(new_version) # type: ignore # pylint: disable=line-too-long
pyproject_toml["tool"]["poetry"]["version"] = str(new_version) # type: ignore # pylint: disable=line-too-long # noqa: E501

self.project_file_path.write_text(
tomlkit.dumps(pyproject_toml), encoding="utf-8"
Expand Down Expand Up @@ -115,14 +115,14 @@ def version_file_path(self) -> Path:
if (
"tool" not in self.pyproject_toml
or "pontos" not in self.pyproject_toml["tool"] # type: ignore
or "version" not in self.pyproject_toml["tool"]["pontos"] # type: ignore # pylint: disable=line-too-long
or "version" not in self.pyproject_toml["tool"]["pontos"] # type: ignore # pylint: disable=line-too-long # noqa: E501
):
raise VersionError(
"[tool.pontos.version] section missing "
f"in {self.project_file_path}."
)

pontos_version_settings = self.pyproject_toml["tool"]["pontos"][ # type: ignore # pylint: disable=line-too-long
pontos_version_settings = self.pyproject_toml["tool"]["pontos"][ # type: ignore # pylint: disable=line-too-long # noqa: E501
"version"
]

Expand Down
1 change: 0 additions & 1 deletion pontos/version/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

from pontos.errors import PontosError

from .__version__ import __version__
from .parser import parse_args
from .project import Project
from .schemes import VersioningScheme
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ lxml = ">=4.9.0"

[tool.poetry.dev-dependencies]
autohooks = { version = ">=22.7.0", python = "^3.9" }
autohooks-plugin-pylint = { version = ">=21.6.0", python = "^3.9" }
autohooks-plugin-black = { version = ">=22.7.0", python = "^3.9" }
autohooks-plugin-isort = { version = ">=22.3.0", python = "^3.9" }
autohooks-plugin-ruff = { version = ">=23.6.1", python = "^3.9" }
rope = ">=1.9.0"
coverage = ">=7.2"
myst-parser = ">=0.19.1"
Expand All @@ -76,13 +76,17 @@ exclude = '''
'''

[tool.autohooks]
pre-commit = ['autohooks.plugins.black', 'autohooks.plugins.isort', 'autohooks.plugins.pylint']
pre-commit = ['autohooks.plugins.black', 'autohooks.plugins.isort', 'autohooks.plugins.ruff']
mode = "poetry"

[tool.isort]
profile = "black"
line_length = 80

[tool.ruff]
line-length = 80
target-version = "py39"

[tool.pontos.version]
version-module-file = "pontos/version/__version__.py"

Expand Down
2 changes: 1 addition & 1 deletion tests/git/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ def test_log(self, exec_git_mock):
Date: Wed Apr 8 14:28:53 2020 +0200
Initial commit
"""
""" # noqa: E501

git = Git()
logs = git.log()
Expand Down
6 changes: 3 additions & 3 deletions tests/github/actions/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_warning(self, print_mock):
title="Foo Bar",
)
print_mock.assert_called_once_with(
"::warning file=bar,line=123,endLine=234,col=1,endColumn=2,title=Foo Bar::foo" # pylint: disable=line-too-long
"::warning file=bar,line=123,endLine=234,col=1,endColumn=2,title=Foo Bar::foo" # pylint: disable=line-too-long # noqa: E501
)

def test_error(self, print_mock):
Expand All @@ -64,7 +64,7 @@ def test_error(self, print_mock):
title="Foo Bar",
)
print_mock.assert_called_once_with(
"::error file=bar,line=123,endLine=234,col=1,endColumn=2,title=Foo Bar::foo" # pylint: disable=line-too-long
"::error file=bar,line=123,endLine=234,col=1,endColumn=2,title=Foo Bar::foo" # pylint: disable=line-too-long # noqa: E501
)

def test_notice(self, print_mock):
Expand All @@ -78,7 +78,7 @@ def test_notice(self, print_mock):
title="Foo Bar",
)
print_mock.assert_called_once_with(
"::notice file=bar,line=123,endLine=234,col=1,endColumn=2,title=Foo Bar::foo" # pylint: disable=line-too-long
"::notice file=bar,line=123,endLine=234,col=1,endColumn=2,title=Foo Bar::foo" # pylint: disable=line-too-long # noqa: E501
)

def test_log(self, print_mock):
Expand Down
3 changes: 2 additions & 1 deletion tests/github/api/test_pull_requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=redefined-builtin, line-too-long, too-many-lines
# ruff: noqa: E501

from pathlib import Path
from unittest.mock import MagicMock
Expand Down Expand Up @@ -770,7 +771,7 @@ async def test_commits(self):
{
"url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"sha": "6dcb09b5b57875f334f61aebed695e2e4193db53",
"node_id": "MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==",
"node_id": "MDY6Q29tbWl0NmRjYjA5YjViNTc4NzVmMzM0ZjYxYWViZWQ2OTVlMmU0MTkzZGI1ZQ==", # noqa: E501
"html_url": "https://github.com/octocat/Hello-World/commit/6dcb09b5b57875f334f61aebed695e2e4193db5e",
"comments_url": "https://api.github.com/repos/octocat/Hello-World/commits/6dcb09b5b57875f334f61aebed695e2e4193db5e/comments",
"commit": {
Expand Down
1 change: 1 addition & 0 deletions tests/github/api/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=too-many-lines, redefined-builtin, line-too-long
# ruff: noqa: E501

from datetime import datetime, timezone
from unittest.mock import MagicMock
Expand Down
1 change: 1 addition & 0 deletions tests/github/models/test_organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=line-too-long, redefined-builtin
# ruff: noqa: E501

import unittest
from datetime import datetime, timezone
Expand Down
1 change: 1 addition & 0 deletions tests/github/models/test_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=line-too-long
# ruff: noqa: E501

import unittest
from datetime import datetime, timezone
Expand Down
1 change: 1 addition & 0 deletions tests/nvd/cpe/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=line-too-long, arguments-differ, redefined-builtin
# ruff: noqa: E501

from datetime import datetime
from typing import Any, Dict, List, Optional
Expand Down
1 change: 1 addition & 0 deletions tests/nvd/models/test_cpe.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=line-too-long
# ruff: noqa: E501

import unittest
from datetime import datetime
Expand Down
1 change: 1 addition & 0 deletions tests/nvd/models/test_cve.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# pylint: disable=line-too-long
# ruff: noqa: E501

import unittest
from datetime import date, datetime
Expand Down
Loading

0 comments on commit a4d0d4d

Please sign in to comment.