Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruff target Python version, update code #702

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions prospector/postfilter.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from pathlib import Path
from typing import List

from prospector.message import Message
from prospector.suppression import get_suppressions


def filter_messages(filepaths: List[Path], messages: List[Message]) -> List[Message]:
def filter_messages(filepaths: list[Path], messages: list[Message]) -> list[Message]:
"""
This method post-processes all messages output by all tools, in order to filter
out any based on the overall output.
Expand Down
3 changes: 1 addition & 2 deletions prospector/tools/pylint/collector.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from io import StringIO
from typing import List

from pylint.exceptions import UnknownMessageError
from pylint.message import Message as PylintMessage
Expand Down Expand Up @@ -35,5 +34,5 @@ def handle_message(self, msg: PylintMessage) -> None:
message = Message("pylint", msg_symbol, loc, msg.msg)
self._messages.append(message)

def get_messages(self) -> List[Message]:
def get_messages(self) -> list[Message]:
return self._messages
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ build-backend = "poetry.core.masonry.api"

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

[tool.ruff.lint]
fixable = ["ALL"]
Expand Down
6 changes: 4 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ def patch_cwd(set_cwd: Path):
# for this test to work in all python versions prospector supports, both need to
# be patched (or, an "if python version" statement but it's easier to just patch both)
cwd_str = str(set_cwd.absolute())
with patch("pathlib.Path.cwd", new=lambda: set_cwd), patch("os.getcwd", new=lambda: cwd_str), patch(
"os.curdir", new=cwd_str
with (
patch("pathlib.Path.cwd", new=lambda: set_cwd),
patch("os.getcwd", new=lambda: cwd_str),
patch("os.curdir", new=cwd_str),
):
# Turns out that Python 3.10 added the `getcwd` to the _NormalAccessor instead of falling
# back on os.getcwd, and so this needs to be patched too...
Expand Down
Loading