Skip to content

Commit 554e375

Browse files
authored
Merge pull request #2086 from praw-dev/clean-up
Clean up typing
2 parents 2e09ecb + 9853397 commit 554e375

54 files changed

Lines changed: 719 additions & 711 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ repos:
2222
- id: ruff
2323
args: [ --exit-non-zero-on-fix, --fix ]
2424
files: ^(praw/.*.py)$
25-
rev: v0.13.3
25+
rev: v0.15.0
2626

2727
- repo: https://github.com/LilSpazJoekp/docstrfmt
2828
hooks:
2929
- id: docstrfmt
30-
rev: v1.11.1
30+
rev: v2.0.2
3131

3232
- repo: https://github.com/MarcoGorelli/auto-walrus
3333
hooks:
3434
- id: auto-walrus
35-
rev: 0.3.4
35+
rev: 0.4.1
3636

3737
- repo: https://github.com/pappasam/toml-sort
3838
hooks:

CHANGES.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Unreleased
1010

1111
- Add support for Python 3.13.
1212
- Add support for optional Markdown-formatted ``selftext`` when submitting link, image,
13-
gallery and video posts.
13+
gallery, and video posts.
1414

1515
**Changed**
1616

@@ -33,6 +33,7 @@ Unreleased
3333
- :meth:`.Subreddit.submit_video`, :meth:`.Subreddit.submit_gallery`, and
3434
:meth:`.Subreddit.submit_image` now accept an optional Markdown-formatted ``selftext``
3535
parameter.
36+
- The ``reason_id`` argument to :class:`.RemovalReason` has been renamed to ``id``.
3637

3738
**Removed**
3839

MANIFEST.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
include CHANGES.rst LICENSE.txt README.rst
22
include praw/praw.ini
33
include "praw/images/PRAW logo.png"
4-
include docs/Makefile
5-
recursive-include docs *.png *.py *.rst
6-
recursive-include tests *.json *.py
7-
recursive-include tests/files *

docs/getting_started/configuration.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ certificate without an exception from requests_, first export the certificate as
5555
import praw
5656
from requests import Session
5757
58-
5958
session = Session()
6059
session.verify = "/path/to/certfile.pem"
6160
reddit = praw.Reddit(
Lines changed: 45 additions & 45 deletions
Loading

docs/package_info/glossary.rst

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,11 @@ Glossary
1414

1515
Here is a list of the six different types of objects returned from Reddit:
1616

17-
.. _fullname_t1:
18-
1917
- ``t1`` These objects represent :class:`.Comment`\ s.
20-
21-
.. _fullname_t2:
22-
2318
- ``t2`` These objects represent :class:`.Redditor`\ s.
24-
25-
.. _fullname_t3:
26-
2719
- ``t3`` These objects represent :class:`.Submission`\ s.
28-
29-
.. _fullname_t4:
30-
3120
- ``t4`` These objects represent :class:`.Message`\ s.
32-
33-
.. _fullname_t5:
34-
3521
- ``t5`` These objects represent :class:`.Subreddit`\ s.
36-
37-
.. _fullname_t6:
38-
3922
- ``t6`` These objects represent :class:`.Trophy`\ s.
4023

4124
.. _websocket:

praw/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
from __future__ import annotations
44

55
import configparser
6-
import importlib.resources
76
import os
7+
from importlib.resources import files
88
from pathlib import Path
99
from threading import Lock
1010
from types import MappingProxyType
@@ -49,7 +49,7 @@ def _load_config(cls, *, config_interpolation: str | None = None) -> None:
4949
interpolator_class = None
5050

5151
config = configparser.ConfigParser(interpolation=interpolator_class)
52-
with importlib.resources.files(__package__).joinpath("praw.ini").open("r") as hdl:
52+
with files(__package__).joinpath("praw.ini").open("r") as hdl:
5353
config.read_file(hdl)
5454

5555
if "APPDATA" in os.environ: # Windows

praw/models/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _safely_add_arguments(*, arguments: dict[str, Any], key: str, **new_argument
2626
arguments[key] = value
2727

2828
@classmethod
29-
def parse(cls, data: dict[str, Any], reddit: praw.Reddit) -> Any:
29+
def parse(cls, data: dict[str, Any], reddit: praw.Reddit) -> PRAWBase:
3030
"""Return an instance of ``cls`` from ``data``.
3131
3232
:param data: The structured data.

praw/models/comment_forest.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from praw.models.reddit.more import MoreComments
1010

1111
if TYPE_CHECKING:
12-
import praw.models
12+
from praw import models
1313

1414

1515
class CommentForest:
@@ -19,7 +19,7 @@ class CommentForest:
1919
2020
"""
2121

22-
def __getitem__(self, index: int) -> praw.models.Comment:
22+
def __getitem__(self, index: int) -> models.Comment:
2323
"""Return the comment at position ``index`` in the list.
2424
2525
This method is to be used like an array access, such as:
@@ -43,7 +43,7 @@ def __len__(self) -> int:
4343
"""Return the number of top-level comments in the forest."""
4444
return len(self._comments)
4545

46-
def _insert_comment(self, comment: praw.models.Comment) -> None:
46+
def _insert_comment(self, comment: models.Comment) -> None:
4747
if comment.name in self._submission._comments_by_id:
4848
raise DuplicateReplaceException
4949
comment.submission = self._submission
@@ -58,7 +58,7 @@ def _insert_comment(self, comment: praw.models.Comment) -> None:
5858

5959
def list(
6060
self,
61-
) -> list[praw.models.Comment | praw.models.MoreComments]:
61+
) -> list[models.Comment | models.MoreComments]:
6262
"""Return a flattened list of all comments.
6363
6464
This list may contain :class:`.MoreComments` instances if :meth:`.replace_more`
@@ -76,9 +76,9 @@ def list(
7676

7777
@staticmethod
7878
def _gather_more_comments(
79-
tree: list[praw.models.MoreComments],
79+
tree: list[models.MoreComments],
8080
*,
81-
parent_tree: list[praw.models.MoreComments] | None = None,
81+
parent_tree: list[models.MoreComments] | None = None,
8282
) -> list[MoreComments]:
8383
"""Return a list of :class:`.MoreComments` objects obtained from tree."""
8484
more_comments = []
@@ -98,8 +98,8 @@ def _gather_more_comments(
9898

9999
def __init__(
100100
self,
101-
submission: praw.models.Submission,
102-
comments: list[praw.models.Comment] | None = None,
101+
submission: models.Submission,
102+
comments: list[models.Comment] | None = None,
103103
) -> None:
104104
"""Initialize a :class:`.CommentForest` instance.
105105
@@ -112,12 +112,12 @@ def __init__(
112112
self._comments = comments
113113
self._submission = submission
114114

115-
def _update(self, comments: list[praw.models.Comment]) -> None:
115+
def _update(self, comments: list[models.Comment]) -> None:
116116
self._comments = comments
117117
for comment in comments:
118118
comment.submission = self._submission
119119

120-
def replace_more(self, *, limit: int | None = 32, threshold: int = 0) -> list[praw.models.MoreComments]:
120+
def replace_more(self, *, limit: int | None = 32, threshold: int = 0) -> list[models.MoreComments]:
121121
"""Update the comment forest by resolving instances of :class:`.MoreComments`.
122122
123123
:param limit: The maximum number of :class:`.MoreComments` instances to replace.

0 commit comments

Comments
 (0)