Skip to content

Commit

Permalink
Merge pull request #702 from prospector-dev/ruff-target-version
Browse files Browse the repository at this point in the history
Add Ruff target Python version, update code
  • Loading branch information
sbrunner authored Nov 14, 2024
2 parents ea78530 + c918ea4 commit 132a13a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
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

0 comments on commit 132a13a

Please sign in to comment.