Skip to content
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ repos:
id: ruff
- id: ruff-format
repo: https://github.com/astral-sh/ruff-pre-commit
rev: 01a675ea018f2fb714478a5ffb83fcea8374bb06 # frozen: v0.15.21
rev: 2700fd5671c633760d912769c041bfcde2b9a01b # frozen: v0.15.22

- hooks:
- files: ^(.*\.toml)$
Expand Down
2 changes: 1 addition & 1 deletion praw/const.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""PRAW constants."""

from praw.endpoints import API_PATH # noqa: F401
from praw.endpoints import API_PATH # ruff:ignore[unused-import]

JPEG_HEADER = b"\xff\xd8\xff"

Expand Down
2 changes: 1 addition & 1 deletion praw/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from typing import cast


class PRAWException(Exception): # noqa: N818
class PRAWException(Exception): # ruff:ignore[error-suffix-on-exception-name]
"""The base PRAW Exception that all other exception classes extend."""


Expand Down
2 changes: 1 addition & 1 deletion praw/models/listing/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _extract_sublist(self, listing: Listing | dict[str, Any] | list[Listing]) ->
for listing_type in classes:
if listing_type.CHILD_ATTRIBUTE in listing:
return listing_type(self._reddit, listing)
else: # noqa: PLW0120
else: # ruff:ignore[useless-else-on-loop]
msg = "The generator returned a dictionary PRAW didn't recognize. File a bug report at PRAW."
raise ValueError(msg)
return listing
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def __setattr__(
if attribute == "author":
value = Redditor.from_data(self._reddit, value)
elif attribute == "replies":
listing: Any = None if value == "" else self._reddit._objector.objectify(data=value) # noqa: PLC1901
listing: Any = None if value == "" else self._reddit._objector.objectify(data=value) # ruff:ignore[compare-to-empty-string]
value = [] if listing is None else listing.children
attribute = "_replies"
elif attribute == "subreddit":
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def update(
data = {"name": self.name}
for attribute, value in mapping.items():
if value is None:
value = getattr(self, attribute) # noqa: PLW2901
value = getattr(self, attribute) # ruff:ignore[redefined-loop-name]
data[attribute] = value
url = API_PATH["emoji_update"].format(subreddit=self.subreddit)
self._reddit.post(url, data=data)
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/live.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ def discussions(self, **generator_kwargs: Any) -> Iterator[models.Submission]:
url = API_PATH["live_discussions"].format(id=self.id)
return ListingGenerator(self._reddit, url, **generator_kwargs)

def report(self, type: str) -> None: # noqa: A002
def report(self, type: str) -> None: # ruff:ignore[builtin-argument-shadowing]
"""Report the thread violating the Reddit rules.

:param type: One of ``"spam"``, ``"vote-manipulation"``,
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def send_removal_message(
*,
message: str,
title: str = "ignored",
type: str = "public", # noqa: A002
type: str = "public", # ruff:ignore[builtin-argument-shadowing]
) -> models.Comment | None:
"""Send a removal message for a :class:`.Comment` or :class:`.Submission`.

Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/editable.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class EditableMixin:
edited: bool | float

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

@property
def edited_datetime(self) -> datetime.datetime | None:
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/inboxable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InboxableMixin:
_reddit: praw.Reddit

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

def block(self) -> None:
"""Block the user who sent the item.
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/inboxtoggleable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class InboxToggleableMixin:
_reddit: praw.Reddit

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

def disable_inbox_replies(self) -> None:
"""Disable inbox replies for the item.
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/replyable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ReplyableMixin:
_reddit: praw.Reddit

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

def reply(self, body: str) -> models.Comment | models.Message | None:
"""Reply to the object.
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/reportable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ReportableMixin:
_reddit: praw.Reddit

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

def report(self, reason: str) -> None:
"""Report this object to the moderators of its subreddit.
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/savable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class SavableMixin:
_reddit: praw.Reddit

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

def save(self, *, category: str | None = None) -> None:
"""Save the object.
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/mixins/votable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class VotableMixin:
_reddit: praw.Reddit

@property
def fullname(self) -> str: ... # noqa: D102
def fullname(self) -> str: ... # ruff:ignore[undocumented-public-method]

def _vote(self, direction: int) -> None:
self._reddit.post(API_PATH["vote"], data={"dir": str(direction), "id": self.fullname})
Expand Down
6 changes: 3 additions & 3 deletions praw/models/reddit/redditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def notes(self) -> models.RedditorModNotes:
print(f"{note.label}: {note.note}")

"""
from praw.models.mod_notes import RedditorModNotes # noqa: PLC0415
from praw.models.mod_notes import RedditorModNotes # ruff:ignore[import-outside-top-level]

return RedditorModNotes(self._reddit, self)

Expand Down Expand Up @@ -150,7 +150,7 @@ def __init__(
msg = "Exactly one of 'name', 'fullname', or '_data' must be provided."
raise TypeError(msg)
if _data:
assert ( # noqa: PT018
assert ( # ruff:ignore[pytest-composite-assertion]
isinstance(_data, dict) and "name" in _data
), "Please file a bug with PRAW."
self._listing_use_sort = True
Expand All @@ -163,7 +163,7 @@ def __init__(
def __setattr__(self, name: str, value: Any) -> None:
"""Objectify the subreddit attribute."""
if name == "subreddit" and value:
from praw.models.reddit.user_subreddit import UserSubreddit # noqa: PLC0415
from praw.models.reddit.user_subreddit import UserSubreddit # ruff:ignore[import-outside-top-level]

value = UserSubreddit(_data=value, reddit=self._reddit)
super().__setattr__(name, value)
Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/subreddit/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def notes(self) -> models.SubredditModNotes:
print(f"{note.label}: {note.note}")

"""
from praw.models.mod_notes import SubredditModNotes # noqa: PLC0415
from praw.models.mod_notes import SubredditModNotes # ruff:ignore[import-outside-top-level]

return SubredditModNotes(self.subreddit._reddit, subreddit=self.subreddit)

Expand Down
2 changes: 1 addition & 1 deletion praw/models/reddit/subreddit/subreddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,7 +1086,7 @@ def submit(
raise TypeError(msg)
kind = provided[0] if provided else None
# test for empty string in selftext for title-only submissions
if kind is None and not (bool(selftext) or selftext == ""): # noqa: PLC1901
if kind is None and not (bool(selftext) or selftext == ""): # ruff:ignore[compare-to-empty-string]
msg = "At least one of 'gallery', 'image', 'poll', 'selftext', 'url', or 'video' must be provided."
raise TypeError(msg)
if inline_media and kind is not None:
Expand Down
2 changes: 1 addition & 1 deletion praw/models/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def __init__(self, max_counter: int) -> None:
def counter(self) -> int | float:
"""Increment the counter and return the current value with jitter."""
max_jitter = self._base / 16.0
value = self._base + random.random() * max_jitter - max_jitter / 2 # noqa: S311
value = self._base + random.random() * max_jitter - max_jitter / 2 # ruff:ignore[suspicious-non-cryptographic-random-usage]
self._base = min(self._base * 2, self._max)
return value

Expand Down
4 changes: 2 additions & 2 deletions praw/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def request(self, *args, **kwargs):

try:
config_section = (
site_name or os.getenv("praw_site") or "DEFAULT" # noqa: SIM112
site_name or os.getenv("praw_site") or "DEFAULT" # ruff:ignore[uncapitalized-environment-variables]
)
self.config = Config(config_section, config_interpolation, **config_settings)
except configparser.NoSectionError as exc:
Expand Down Expand Up @@ -429,7 +429,7 @@ def _check_for_async(self) -> None:
try:
asyncio.get_running_loop()
in_async = True
except Exception: # noqa: BLE001,S110
except Exception: # ruff:ignore[blind-except, try-except-pass]
pass # Quietly fail if any exception occurs during the check
if in_async:
logger.warning(
Expand Down
2 changes: 1 addition & 1 deletion praw/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from collections.abc import Callable


class cachedproperty: # noqa: N801
class cachedproperty: # ruff:ignore[invalid-class-name]
"""A decorator for caching a property's result.

Similar to :py:class:`property`, but the wrapped method's result is cached on the
Expand Down