Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ repos:
- id: ruff
args: [ --exit-non-zero-on-fix, --fix ]
files: ^(prawcore/.*.py)$

- repo: https://github.com/psf/black
hooks:
- id: black
rev: 24.10.0
- id: ruff-format

- repo: https://github.com/LilSpazJoekp/docstrfmt
hooks:
Expand Down
10 changes: 7 additions & 3 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ prawcore follows `semantic versioning <https://semver.org/>`_.
Unreleased
----------

**Changed**

- Drop support for Python 3.8, which was end-of-life on 2024-10-07.

2.4.0 (2023/10/01)
------------------

**Changed**

- Drop support for Python 3.6, which is end-of-life on 2021-12-23.
- Drop support for Python 3.6, which was end-of-life on 2021-12-23.
- Updated rate limit algorithm to better handle Reddit's new rate limits.
- Drop support for Python 3.7, which is end-of-life on 2023-06-27.
- Drop support for Python 3.7, which was end-of-life on 2023-06-27.

2.3.0 (2021-07-26)
------------------
Expand Down Expand Up @@ -75,7 +79,7 @@ Unreleased

**Changed**

- Drop support for Python 3.5, which is end-of-life on 2020-09-13.
- Drop support for Python 3.5, which was end-of-life on 2020-09-13.

1.4.0 (2020-05-28)
------------------
Expand Down
4 changes: 0 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ prawcore
:alt: pre-commit
:target: https://github.com/pre-commit/pre-commit

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:alt: Black code style
:target: https://github.com/psf/black

prawcore is a low-level communication layer used by PRAW 4+.

Installation
Expand Down
1 change: 1 addition & 0 deletions examples/obtain_refresh_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
application OAuth2 credentials.

"""

import os
import random
import socket
Expand Down
1 change: 1 addition & 0 deletions examples/read_only_auth_trophies.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
require an access token to make authenticated requests to Reddit.

"""

import os
import sys

Expand Down
1 change: 1 addition & 0 deletions examples/script_auth_friend_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
password.

"""

import os
import sys

Expand Down
2 changes: 1 addition & 1 deletion prawcore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
""""Low-level communication layer for PRAW 4+."""
"""Low-level communication layer for PRAW 4+."""

import logging

Expand Down
3 changes: 2 additions & 1 deletion prawcore/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
REVOKE_TOKEN_PATH = "/api/v1/revoke_token" # noqa: S105
TIMEOUT = float(
os.environ.get(
"PRAWCORE_TIMEOUT", os.environ.get("prawcore_timeout", 16) # noqa: SIM112
"PRAWCORE_TIMEOUT",
os.environ.get("prawcore_timeout", 16), # noqa: SIM112
)
)
WINDOW_SIZE = 600
4 changes: 3 additions & 1 deletion prawcore/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import logging
import time
from typing import TYPE_CHECKING, Any, Callable, Mapping
from typing import TYPE_CHECKING, Any, Callable

if TYPE_CHECKING:
from collections.abc import Mapping

from requests.models import Response

log = logging.getLogger(__package__)
Expand Down
13 changes: 5 additions & 8 deletions prawcore/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,8 @@ def _make_request(
)
return response, None
except RequestException as exception:
if (
not retry_strategy_state.should_retry_on_failure()
or not isinstance( # noqa: E501
exception.original_exception, self.RETRY_EXCEPTIONS
)
if not retry_strategy_state.should_retry_on_failure() or not isinstance( # noqa: E501
exception.original_exception, self.RETRY_EXCEPTIONS
):
raise
return None, exception.original_exception
Expand Down Expand Up @@ -266,9 +263,9 @@ def _request_with_retries(
raise self.STATUS_EXCEPTIONS[response.status_code](response)
if response.status_code == codes["no_content"]:
return None
assert (
response.status_code in self.SUCCESS_STATUSES
), f"Unexpected status code: {response.status_code}"
assert response.status_code in self.SUCCESS_STATUSES, (
f"Unexpected status code: {response.status_code}"
)
if response.headers.get("content-length") == "0":
return ""
try:
Expand Down
2 changes: 1 addition & 1 deletion pre_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def main():
"-n",
"--unstatic",
action="store_true",
help="Do not run static tests (black/flake8/pydocstyle)",
help="Do not run static tests (ruff)",
default=False,
)
parser.add_argument(
Expand Down
18 changes: 5 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ classifiers = [
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12"
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13"
]
dependencies = [
"requests >=2.6.0, <3.0"
Expand All @@ -29,7 +29,7 @@ maintainers = [
]
name = "prawcore"
readme = "README.rst"
requires-python = "~=3.8"
requires-python = "~=3.9"

[project.optional-dependencies]
ci = ["coveralls"]
Expand All @@ -40,7 +40,7 @@ dev = [
]
lint = [
"pre-commit",
"ruff ==0.1.*"
"ruff ==0.9.*"
]
test = [
"betamax >=0.8, <0.9",
Expand All @@ -52,16 +52,8 @@ test = [
"Issue Tracker" = "https://github.com/praw-dev/prawcore/issues"
"Source Code" = "https://github.com/praw-dev/prawcore"

[tool.black]
extend_exclude = '/(\.venv.*)/'
line-length = 88

[tool.isort]
profile = 'black'
skip_glob = '.venv*'

[tool.ruff]
target-version = "py38"
target-version = "py39"
include = [
"prawcore/*.py"
]
Expand Down
4 changes: 2 additions & 2 deletions tools/set_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def add_unreleased_to_changelog():
return False

with open("CHANGES.rst", "w") as fp:
fp.write(f"{new_header}{content[len(CHANGELOG_HEADER):]}")
fp.write(f"{new_header}{content[len(CHANGELOG_HEADER) :]}")
return True


Expand Down Expand Up @@ -84,7 +84,7 @@ def update_changelog(version):
version_header = f"{version_line}{'-' * len(version_line[:-1])}\n\n"

with open("CHANGES.rst", "w") as fp:
fp.write(f"{CHANGELOG_HEADER}{version_header}{content[len(expected_header):]}")
fp.write(f"{CHANGELOG_HEADER}{version_header}{content[len(expected_header) :]}")
return True


Expand Down
Loading