Skip to content

Commit

Permalink
Merge remote-tracking branch 'source/master' into window-size-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Watchful1 committed Sep 23, 2024
2 parents c9519e6 + c768c3a commit 0f790df
Show file tree
Hide file tree
Showing 108 changed files with 215 additions and 150 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[report]
exclude_lines =
@abstract
if TYPE_CHECKING:
pragma: no cover
31 changes: 0 additions & 31 deletions .github/workflows/codeql.yml

This file was deleted.

7 changes: 4 additions & 3 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ jobs:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
cache: pip
python-version: 3.x
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/scorecards-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
jobs:
analysis:
name: Scorecards analysis
name: Scorecard analysis
permissions:
actions: read
contents: read
id-token: write
security-events: write
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
persist-credentials: false
- name: Run analysis
uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1
with:
results_file: results.sarif
results_format: sarif
repo_token: ${{ secrets.SCORECARD_READ_TOKEN }}
publish_results: true
- name: Upload artifact
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb # v3.1.1
uses: actions/upload-artifact@97a0fba1372883ab732affbe8f94b823f91727db # v3.pre.node20
with:
name: SARIF file
path: results.sarif
retention-days: 5
- name: Upload to code-scanning
uses: github/codeql-action/upload-sarif@5f532563584d71fdef14ee64d17bafb34f751ce5 # v1.0.26
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: results.sarif
name: Scorecards supply-chain security
name: Scorecard supply-chain security
on:
branch_protection_rule:
push:
branches: [ master ]
schedule:
- cron: 30 1 * * 6
- cron: 0 15 * * 1
permissions: read-all
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ repos:
types: [ python ]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-executables-have-shebangs
Expand All @@ -42,7 +42,7 @@ repos:
files: ^(.*\.toml)$

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.11
rev: v0.6.2
hooks:
- id: ruff
args: [ --exit-non-zero-on-fix, --fix ]
Expand All @@ -51,9 +51,9 @@ repos:
- repo: https://github.com/psf/black
hooks:
- id: black
rev: 23.12.1
rev: 24.8.0

- repo: https://github.com/LilSpazJoekp/docstrfmt
hooks:
- id: docstrfmt
rev: v1.6.1
rev: v1.8.0
7 changes: 0 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,3 @@ PRAW's source (v4.0.0+) is provided under the `Simplified BSD License

Earlier versions of PRAW were released under `GPLv3
<https://github.com/praw-dev/praw/blob/0c88697fdc26e75f87b68e2feb11e101e90ce215/COPYING>`_.

Sponsors
--------

.. image:: https://github.com/praw-dev/praw/blob/36fa3060b8938815feb45d07541877c8ce994cbb/docs/package_info/NucleiLogo.png
:alt: Nuclei
:target: https://nuclei.ai
1 change: 1 addition & 0 deletions praw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
More information about PRAW can be found at https://github.com/praw-dev/praw.
"""

from .const import __version__
from .reddit import Reddit
1 change: 1 addition & 0 deletions praw/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provides the code to load PRAW's configuration file ``praw.ini``."""

from __future__ import annotations

import configparser
Expand Down
1 change: 1 addition & 0 deletions praw/const.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""PRAW constants."""

from .endpoints import API_PATH # noqa: F401

__version__ = "7.7.2.dev0"
Expand Down
1 change: 1 addition & 0 deletions praw/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""List of API endpoints PRAW knows about."""

# fmt: off
API_PATH = {
"about_edited": "r/{subreddit}/about/edited/",
Expand Down
15 changes: 9 additions & 6 deletions praw/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
All other exceptions are subclassed from :class:`.ClientException`.
"""

from __future__ import annotations

from typing import Any
Expand Down Expand Up @@ -216,12 +217,14 @@ def parse_exception_list(
) -> list[RedditErrorItem]:
"""Covert an exception list into a :class:`.RedditErrorItem` list."""
return [
exception
if isinstance(exception, RedditErrorItem)
else RedditErrorItem(
error_type=exception[0],
field=exception[2] if bool(exception[2]) else "",
message=exception[1] if bool(exception[1]) else "",
(
exception
if isinstance(exception, RedditErrorItem)
else RedditErrorItem(
error_type=exception[0],
field=exception[2] if bool(exception[2]) else "",
message=exception[1] if bool(exception[1]) else "",
)
)
for exception in exceptions
]
Expand Down
1 change: 1 addition & 0 deletions praw/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the PRAW models."""

from .auth import Auth
from .front import Front
from .helpers import DraftHelper, LiveHelper, MultiredditHelper, SubredditHelper
Expand Down
3 changes: 2 additions & 1 deletion praw/models/auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the Auth class."""

from __future__ import annotations

from prawcore import Authorizer, ImplicitAuthorizer, UntrustedAuthenticator, session
Expand Down Expand Up @@ -59,7 +60,7 @@ def authorize(self, code: str) -> str | None:
return authorizer.refresh_token

@_deprecate_args("access_token", "expires_in", "scope")
def implicit(self, *, access_token: str, expires_in: int, scope: str) -> None:
def implicit(self, *, access_token: str, expires_in: int, scope: str):
"""Set the active authorization to be an implicit authorization.
:param access_token: The access_token obtained from Reddit's callback.
Expand Down
1 change: 1 addition & 0 deletions praw/models/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the PRAWBase superclass."""

from __future__ import annotations

from copy import deepcopy
Expand Down
55 changes: 28 additions & 27 deletions praw/models/comment_forest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide CommentForest for submission comments."""

from __future__ import annotations

from heapq import heappop, heappush
Expand All @@ -19,28 +20,6 @@ class CommentForest:
"""

@staticmethod
def _gather_more_comments(
tree: list[praw.models.MoreComments],
*,
parent_tree: list[praw.models.MoreComments] | None = None,
) -> list[MoreComments]:
"""Return a list of :class:`.MoreComments` objects obtained from tree."""
more_comments = []
queue = [(None, x) for x in tree]
while queue:
parent, comment = queue.pop(0)
if isinstance(comment, MoreComments):
heappush(more_comments, comment)
if parent:
comment._remove_from = parent.replies._comments
else:
comment._remove_from = parent_tree or tree
else:
for item in comment.replies:
queue.append((comment, item))
return more_comments

def __getitem__(self, index: int) -> praw.models.Comment:
"""Return the comment at position ``index`` in the list.
Expand Down Expand Up @@ -79,11 +58,6 @@ def _insert_comment(self, comment: praw.models.Comment):
parent = self._submission._comments_by_id[comment.parent_id]
parent.replies._comments.append(comment)

def _update(self, comments: list[praw.models.Comment]):
self._comments = comments
for comment in comments:
comment.submission = self._submission

def list( # noqa: A003
self,
) -> list[praw.models.Comment | praw.models.MoreComments]:
Expand All @@ -102,6 +76,28 @@ def list( # noqa: A003
queue.extend(comment.replies)
return comments

@staticmethod
def _gather_more_comments(
tree: list[praw.models.MoreComments],
*,
parent_tree: list[praw.models.MoreComments] | None = None,
) -> list[MoreComments]:
"""Return a list of :class:`.MoreComments` objects obtained from tree."""
more_comments = []
queue = [(None, x) for x in tree]
while queue:
parent, comment = queue.pop(0)
if isinstance(comment, MoreComments):
heappush(more_comments, comment)
if parent:
comment._remove_from = parent.replies._comments
else:
comment._remove_from = parent_tree or tree
else:
for item in comment.replies:
queue.append((comment, item))
return more_comments

def __init__(
self,
submission: praw.models.Submission,
Expand All @@ -118,6 +114,11 @@ def __init__(
self._comments = comments
self._submission = submission

def _update(self, comments: list[praw.models.Comment]):
self._comments = comments
for comment in comments:
comment.submission = self._submission

@_deprecate_args("limit", "threshold")
def replace_more(
self, *, limit: int | None = 32, threshold: int = 0
Expand Down
1 change: 1 addition & 0 deletions praw/models/front.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the Front class."""

from __future__ import annotations

from typing import TYPE_CHECKING, Iterator
Expand Down
8 changes: 4 additions & 4 deletions praw/models/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the helper classes."""

from __future__ import annotations

from json import dumps
Expand Down Expand Up @@ -73,10 +74,9 @@ def create(
selftext: str | None = None,
send_replies: bool = True,
spoiler: bool = False,
subreddit: str
| praw.models.Subreddit
| praw.models.UserSubreddit
| None = None,
subreddit: (
str | praw.models.Subreddit | praw.models.UserSubreddit | None
) = None,
title: str | None = None,
url: str | None = None,
**draft_kwargs: Any,
Expand Down
1 change: 1 addition & 0 deletions praw/models/inbox.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the Front class."""

from __future__ import annotations

from typing import TYPE_CHECKING, Iterator
Expand Down
1 change: 1 addition & 0 deletions praw/models/list/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the BaseList class."""

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Iterator
Expand Down
1 change: 1 addition & 0 deletions praw/models/list/draft.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the DraftList class."""

from .base import BaseList


Expand Down
1 change: 1 addition & 0 deletions praw/models/list/moderated.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the ModeratedList class."""

from .base import BaseList


Expand Down
1 change: 1 addition & 0 deletions praw/models/list/redditor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the RedditorList class."""

from .base import BaseList


Expand Down
1 change: 1 addition & 0 deletions praw/models/list/trophy.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the TrophyList class."""

from .base import BaseList


Expand Down
1 change: 1 addition & 0 deletions praw/models/listing/domain.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the DomainListing class."""

from __future__ import annotations

from typing import TYPE_CHECKING
Expand Down
1 change: 1 addition & 0 deletions praw/models/listing/generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the ListingGenerator class."""

from __future__ import annotations

from copy import deepcopy
Expand Down
3 changes: 2 additions & 1 deletion praw/models/listing/listing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Provide the Listing class."""

from __future__ import annotations

from typing import Any
Expand All @@ -20,7 +21,7 @@ def __len__(self) -> int:
"""Return the number of items in the Listing."""
return len(getattr(self, self.CHILD_ATTRIBUTE))

def __setattr__(self, attribute: str, value: Any) -> None:
def __setattr__(self, attribute: str, value: Any):
"""Objectify the ``CHILD_ATTRIBUTE`` attribute."""
if attribute == self.CHILD_ATTRIBUTE:
value = self._reddit._objector.objectify(value)
Expand Down
Loading

0 comments on commit 0f790df

Please sign in to comment.