Skip to content

Commit 26f4a2d

Browse files
authored
Merge pull request praw-dev#2049 from praw-dev/cleanup
Cleanup
2 parents ddab378 + 4f508c7 commit 26f4a2d

88 files changed

Lines changed: 620 additions & 1025 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,29 @@ repos:
1717
pass_filenames: false
1818
types: [ python ]
1919

20+
- repo: https://github.com/astral-sh/ruff-pre-commit
21+
hooks:
22+
- id: ruff
23+
args: [ --exit-non-zero-on-fix, --fix ]
24+
files: ^(praw/.*.py)$
25+
rev: v0.9.4
26+
27+
- repo: https://github.com/LilSpazJoekp/docstrfmt
28+
hooks:
29+
- id: docstrfmt
30+
rev: v1.9.0
31+
32+
- repo: https://github.com/MarcoGorelli/auto-walrus
33+
hooks:
34+
- id: auto-walrus
35+
rev: 0.3.4
36+
37+
- repo: https://github.com/pappasam/toml-sort
38+
hooks:
39+
- id: toml-sort-fix
40+
files: ^(.*\.toml)$
41+
rev: v0.24.2
42+
2043
- repo: https://github.com/pre-commit/pre-commit-hooks
2144
rev: v5.0.0
2245
hooks:
@@ -31,29 +54,7 @@ repos:
3154
- id: name-tests-test
3255
args: [ --pytest-test-first ]
3356
files: ^tests/integration/.*\.py|tests/unit/.*\.py$
57+
- id: no-commit-to-branch
3458
- id: sort-simple-yaml
3559
files: ^(\.github/workflows/.*\.ya?ml|\.readthedocs.ya?ml)$
3660
- id: trailing-whitespace
37-
38-
- repo: https://github.com/pappasam/toml-sort
39-
rev: v0.24.2
40-
hooks:
41-
- id: toml-sort-fix
42-
files: ^(.*\.toml)$
43-
44-
- repo: https://github.com/astral-sh/ruff-pre-commit
45-
rev: v0.9.4
46-
hooks:
47-
- id: ruff
48-
args: [ --exit-non-zero-on-fix, --fix ]
49-
files: ^(praw/.*.py)$
50-
51-
- repo: https://github.com/psf/black
52-
hooks:
53-
- id: black
54-
rev: 25.1.0
55-
56-
- repo: https://github.com/LilSpazJoekp/docstrfmt
57-
hooks:
58-
- id: docstrfmt
59-
rev: v1.9.0

docs/code_overview/other.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ them bound to an attribute of one of the PRAW models.
132132
other/inboxablemixin
133133
other/listinggenerator
134134
other/mod_action
135-
other/mod_note
136135
other/moderatedlist
137136
other/modmail
138137
other/modmailmessage

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
from praw import __version__ # noqa: E402
99

10+
autodoc_typehints = "description"
1011
copyright = datetime.today().strftime("%Y, Bryce Boe")
1112
exclude_patterns = ["_build"]
1213
extensions = [
1314
"sphinx.ext.autodoc",
1415
"sphinx.ext.intersphinx",
16+
"sphinx_autodoc_typehints",
1517
]
1618
html_theme = "furo"
1719
htmlhelp_basename = "PRAW"

docs/examples/obtain_refresh_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def main():
5656
f"State mismatch. Expected: {state} Received: {params['state']}",
5757
)
5858
return 1
59-
elif "error" in params:
59+
if "error" in params:
6060
send_message(client, params["error"])
6161
return 1
6262

docs/examples/use_file_token_manager.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ def main():
5454
if scopes == {"*"}:
5555
print(f"{reddit.user.me()} is authenticated with all scopes")
5656
return None
57-
elif "identity" in scopes:
57+
if "identity" in scopes:
5858
print(
5959
f"{reddit.user.me()} is authenticated with the following scopes: {scopes}"
6060
)
6161
return None
62-
else:
63-
print(f"You are authenticated with the following scopes: {scopes}")
64-
return None
62+
print(f"You are authenticated with the following scopes: {scopes}")
63+
return None
6564

6665

6766
if __name__ == "__main__":

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ application. See :ref:`oauth` for information on using **installed** application
6262
package_info/glossary
6363
package_info/praw7_migration
6464
package_info/references
65-
package_info/sponsors
6665

6766
.. toctree::
6867
:hidden:

docs/package_info/NucleiLogo.png

-15.1 KB
Binary file not shown.

docs/package_info/sponsors.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.

praw/config.py

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ def _fetch(self, key: str) -> Any:
106106
del self.custom[key]
107107
return value
108108

109-
def _fetch_default(
110-
self, key: str, *, default: bool | float | str | None = None
111-
) -> Any:
109+
def _fetch_default(self, key: str, *, default: bool | float | str | None = None) -> Any:
112110
if key not in self.custom:
113111
return default
114112
return self._fetch(key)
@@ -125,15 +123,9 @@ def _fetch_or_not_set(self, key: str) -> Any | _NotSet:
125123

126124
def _initialize_attributes(self):
127125
self._short_url = self._fetch_default("short_url") or self.CONFIG_NOT_SET
128-
self.check_for_async = self._config_boolean(
129-
self._fetch_default("check_for_async", default=True)
130-
)
131-
self.check_for_updates = self._config_boolean(
132-
self._fetch_or_not_set("check_for_updates")
133-
)
134-
self.warn_comment_sort = self._config_boolean(
135-
self._fetch_default("warn_comment_sort", default=True)
136-
)
126+
self.check_for_async = self._config_boolean(self._fetch_default("check_for_async", default=True))
127+
self.check_for_updates = self._config_boolean(self._fetch_or_not_set("check_for_updates"))
128+
self.warn_comment_sort = self._config_boolean(self._fetch_default("warn_comment_sort", default=True))
137129
self.warn_additional_fetch_params = self._config_boolean(
138130
self._fetch_default("warn_additional_fetch_params", default=True)
139131
)

praw/exceptions.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ def __eq__(self, other: RedditErrorItem | list[str]) -> bool:
4343
)
4444
return super().__eq__(other)
4545

46+
def __hash__(self) -> int:
47+
"""Return the hash of the current instance."""
48+
return hash(self.__class__.__name__) ^ hash((self.error_type, self.message, self.field))
49+
4650
@_deprecate_args("error_type", "message", "field")
4751
def __init__(
4852
self,
@@ -65,8 +69,7 @@ def __init__(
6569
def __repr__(self) -> str:
6670
"""Return an object initialization representation of the instance."""
6771
return (
68-
f"{self.__class__.__name__}(error_type={self.error_type!r},"
69-
f" message={self.message!r}, field={self.field!r})"
72+
f"{self.__class__.__name__}(error_type={self.error_type!r}, message={self.message!r}, field={self.field!r})"
7073
)
7174

7275
def __str__(self) -> str:
@@ -84,8 +87,7 @@ class DuplicateReplaceException(ClientException):
8487
def __init__(self):
8588
"""Initialize a :class:`.DuplicateReplaceException` instance."""
8689
super().__init__(
87-
"A duplicate comment has been detected. Are you attempting to call"
88-
" 'replace_more_comments' more than once?"
90+
"A duplicate comment has been detected. Are you attempting to call 'replace_more_comments' more than once?"
8991
)
9092

9193

@@ -145,8 +147,7 @@ def __init__(self, *, actual: int, maximum_size: int):
145147
self.maximum_size = maximum_size
146148
self.actual = actual
147149
super().__init__(
148-
f"The media that you uploaded was too large (maximum size is {maximum_size}"
149-
f" bytes, uploaded {actual} bytes)"
150+
f"The media that you uploaded was too large (maximum size is {maximum_size} bytes, uploaded {actual} bytes)"
150151
)
151152

152153

0 commit comments

Comments
 (0)