You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ship a py.typed marker (PEP 561) and the Typing :: Typed classifier so
downstream projects type check against PRAW's inline annotations; hatchling
bundles the marker into the wheel automatically.
Add a type dependency group with pyright, a [tool.pyright] config, and a tox
type env, and add that env to the tox envlist so the shared CI lint job
enforces zero pyright errors under standard mode. Enable
reportUnnecessaryTypeIgnoreComment to keep ignores from going stale.
Most fixes declare host-provided attributes on the various mixins, add Optional
narrowing, correct return/argument annotations, and add @overload where a
return type depends on argument values (e.g. DraftHelper.__call__). Notable
changes:
- Config: declare its dynamically-populated attributes (client_id, oauth_url,
ratelimit_seconds, etc.) and widen **settings; drop the redundant None
pre-init.
- FullnameMixin._kind and LiveUpdate._kind are now properties so the property
overrides in Comment/Submission/Message/Redditor/Subreddit are compatible.
- ThingModerationMixin.thing is declared so pyright can resolve self.thing
access within the mixin.
- MoreComments, InlineMedia, and similar classes declare attributes set
elsewhere in the object model.
- Listing methods (controversial/hot/new/top, rising, duplicates, comments,
and the Redditor up/down/saved/hidden helpers) type **generator_kwargs with
Unpack[ListingGeneratorKwargs], a TypedDict mirroring ListingGenerator's
limit and params, so the kwargs are precisely typed for downstream callers.
- Subreddit declares the _submission_class and _subreddit_collections_class
attributes that the submission and collections modules bind at import time,
and Listing declares its dynamic children attribute.
- Reddit._check_for_async looks up get_ipython via builtins instead of relying
on the name IPython injects into globals.
Add a DynamicAttributes mixin (a __getattr__ typed to return Any) to the
PRAWBase data classes that are populated from Reddit response data -- Trophy,
Stylesheet, PollData, PollOption, ModNote, Widget, Submenu, and the widget data
classes. RedditBase already returns Any from __getattr__; without this, shipping
py.typed would make every dynamic attribute access (e.g. trophy.icon_70) an
error in downstream projects, which is why a previous py.typed marker was
reverted (#1944). tests/typing/dynamic_attributes.py is added to the pyright
include as a regression guard.
Require prawcore >=3.2, which exposes public Session/authorizer accessors
(Session.authorizer/rate_limiter/requestor, BaseAuthorizer.authenticator,
BaseAuthenticator.requestor) and widens Session.request's parameter annotations.
PRAW now uses those accessors instead of reaching into protected members, and
drops the casts and # pyright: ignore comments that previously papered over the
narrower prawcore annotations. The dead str option is removed from request's
params type, since prawcore has never accepted a raw query string there.
For read-only authorizations this should return ``{"*"}``.
80
83
81
84
"""
82
-
authorizer=self._reddit._core._authorizer
85
+
assertself._reddit._coreisnotNone
86
+
authorizer=self._reddit._core.authorizer
83
87
ifnotauthorizer.is_valid():
84
-
authorizer.refresh()
88
+
authorizer.refresh() # pyright: ignore[reportAttributeAccessIssue] # refresh is defined on Authorizer subclasses; the active core authorizer is always refreshable here
0 commit comments