Skip to content

Commit

Permalink
Add new pre-commit hooks, switch to ruff for most linting checks, lin…
Browse files Browse the repository at this point in the history
…t and clean up code using ruff
  • Loading branch information
LilSpazJoekp committed Aug 28, 2023
1 parent 7d0612c commit 92fc197
Show file tree
Hide file tree
Showing 135 changed files with 1,504 additions and 1,726 deletions.
7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ body:
- id: credential-check
attributes:
label: |
The `Reddit()` initialization in my code example does not include the following parameters to prevent credential leakage:
The `Reddit()` initialization in my code example does not include the following parameters to prevent credential leakage:
`client_secret`, `password`, or `refresh_token`.
options:
- label: "Yes"
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ This pull request provides ...

## References

-
-
17 changes: 11 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,32 @@ repos:
rev: v4.4.0
hooks:
- id: check-added-large-files
args: [ --maxkb=64 ]
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-yaml
- id: end-of-file-fixer
- id: mixed-line-ending
args: [ --fix=no ]
- id: name-tests-test
args: [ --pytest-test-first ]
files: ^tests/integration/.*\.py|tests/unit/.*\.py$
- id: no-commit-to-branch
- id: sort-simple-yaml
files: ^(\.github/workflows/.*\.ya?ml|\.readthedocs.ya?ml)$
- id: trailing-whitespace

- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix
files: ^(.*\.toml)$

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.0.286
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
args: [ --exit-non-zero-on-fix, --fix ]
files: ^(praw/.*.py)$

- repo: https://github.com/psf/black
hooks:
Expand Down
245 changes: 0 additions & 245 deletions .pylintrc

This file was deleted.

2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Supported Versions

The supported versions of PRAW include the previous major release.
The supported versions of PRAW include the previous major release.
This means that if PRAW is on 6.5.0, PRAW versions 5.0.0 and greater are supported.

## Reporting a Vulnerability
Expand Down
2 changes: 1 addition & 1 deletion docs/code_overview/models/awards.txt
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ Ternion All-Powerful .. image:: https://www.redditstatic.com/gold/awards/
heart, mind, and soul. Some might call it
unachievanium. Gives 5,000 Reddit Coins and six
months of r/lounge access and ad-free browsing.
========================== ====================================================================================================================================================================================== ========================================== ================================================== ======
========================== ====================================================================================================================================================================================== ========================================== ================================================== ======
1 change: 1 addition & 0 deletions docs/code_overview/other.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ them bound to an attribute of one of the PRAW models.
other/rule
other/stylesheet
other/sublisting
other/subredditlistingmixin
other/subredditmessage
other/token_manager
other/trophy
Expand Down
Empty file modified docs/code_overview/other/button.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/buttonwidget.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/calendar.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/communitylist.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/customwidget.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/draftlist.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/idcard.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/image.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/imagedata.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/imagewidget.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/menu.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/menulink.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/mod_action.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/moderatorswidget.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/postflairwidget.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/prawbase.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/ruleswidget.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/submenu.rst
100755 → 100644
Empty file.
5 changes: 5 additions & 0 deletions docs/code_overview/other/subredditlistingmixin.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
SubredditListingMixin
=====================

.. autoclass:: praw.models.listing.mixins.subreddit.SubredditListingMixin
:inherited-members:
Empty file modified docs/code_overview/other/subredditwidgets.rst
100755 → 100644
Empty file.
Empty file modified docs/code_overview/other/textarea.rst
100755 → 100644
Empty file.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
nitpick_ignore = [
("py:class", "IO"),
("py:class", "prawcore.requestor.Requestor"),
("py:class", "prawcore.auth.BaseAuthorizer"),
("py:class", "praw.models.redditors.PartialRedditor"),
]
nitpicky = True
Expand Down
6 changes: 2 additions & 4 deletions docs/examples/obtain_refresh_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ def main():
client = receive_connection()
data = client.recv(1024).decode("utf-8")
param_tokens = data.split(" ", 2)[1].split("?", 1)[1].split("&")
params = {
key: value for (key, value) in [token.split("=") for token in param_tokens]
}
params = dict([token.split("=") for token in param_tokens])

if state != params["state"]:
send_message(
Expand Down Expand Up @@ -85,7 +83,7 @@ def receive_connection():
def send_message(client, message):
"""Send message to client and close the connection."""
print(message)
client.send(f"HTTP/1.1 200 OK\r\n\r\n{message}".encode("utf-8"))
client.send(f"HTTP/1.1 200 OK\r\n\r\n{message}".encode())
client.close()


Expand Down
3 changes: 3 additions & 0 deletions docs/examples/use_file_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ def main():
scopes = reddit.auth.scopes()
if scopes == {"*"}:
print(f"{reddit.user.me()} is authenticated with all scopes")
return None
elif "identity" in scopes:
print(
f"{reddit.user.me()} is authenticated with the following scopes: {scopes}"
)
return None
else:
print(f"You are authenticated with the following scopes: {scopes}")
return None


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/authentication_flow_table.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
|Alternative Flows|:ref:`application_only_client_credentials_flow`| | |
+ +-----------------------------------------------+-----------------------------------------------+-------------------------------+
| | :ref:`application_only_installed_client_flow` |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------+
+-----------------+-------------------------------------------------------------------------------------------------------------------------------+
4 changes: 2 additions & 2 deletions praw/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"""

from .const import __version__ # NOQA
from .reddit import Reddit # NOQA
from .const import __version__
from .reddit import Reddit

0 comments on commit 92fc197

Please sign in to comment.