From eb19b7017ccc25a91dc832da33f445f6ce3e89f2 Mon Sep 17 00:00:00 2001 From: LilSpazJoekp <15524072+LilSpazJoekp@users.noreply.github.com> Date: Mon, 12 Aug 2024 17:44:40 -0500 Subject: [PATCH] Clean up code, update workflows, fix ruff issues --- .github/workflows/codeql.yml | 31 ----------------------- .github/workflows/pypi.yml | 7 ++--- .github/workflows/scorecards-analysis.yml | 10 ++++---- .pre-commit-config.yaml | 6 ++--- CHANGES.rst | 2 +- asyncprawcore/auth.py | 2 +- pyproject.toml | 7 ++--- 7 files changed, 18 insertions(+), 47 deletions(-) delete mode 100644 .github/workflows/codeql.yml diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 7c52830..0000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,31 +0,0 @@ -jobs: - analyze: - name: Analyze - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} - permissions: - actions: read - contents: read - security-events: write - strategy: - fail-fast: false - matrix: - language: [ 'python' ] - steps: - - name: Checkout repository - uses: actions/checkout@v3 - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: ${{ matrix.language }} - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 - with: - category: "/language:${{matrix.language}}" -name: "CodeQL" -on: - push: - branches: [ "master" ] - pull_request: - branches: [ "master" ] - schedule: - - cron: 30 1 * * 6 diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 43521cf..321091c 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -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 diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index 3935658..c57dc60 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -1,6 +1,6 @@ jobs: analysis: - name: Scorecards analysis + name: Scorecard analysis permissions: id-token: write security-events: write @@ -23,14 +23,14 @@ jobs: path: results.sarif retention-days: 5 - name: Upload to code-scanning - uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2 # v3.24.9 + 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: [ main ] schedule: - - cron: 30 1 * * 6 -permissions: read-all \ No newline at end of file + - cron: 0 15 * * 1 +permissions: read-all diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 74c5f7e..03a0130 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: files: ^(.*\.toml)$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.5.7 hooks: - id: ruff args: [ --exit-non-zero-on-fix, --fix ] @@ -33,10 +33,10 @@ repos: - repo: https://github.com/psf/black hooks: - id: black - rev: 24.4.2 + rev: 24.8.0 - repo: https://github.com/LilSpazJoekp/docstrfmt hooks: - id: docstrfmt require_serial: true - rev: v1.6.1 + rev: v1.8.0 diff --git a/CHANGES.rst b/CHANGES.rst index 09d77ca..988cdbb 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -13,7 +13,7 @@ Unreleased - Drop support for Python 3.6, which is end-of-life on 2021-12-23. - :class:`DeviceIDAuthorizer` can be now used with :class:`TrustedAuthenticator`. -- Updated rate limit algorithm to better handle reddit's new rate limits. +- 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. 2.3.0 (2021/07/27) diff --git a/asyncprawcore/auth.py b/asyncprawcore/auth.py index ac1c63f..7ebaf12 100644 --- a/asyncprawcore/auth.py +++ b/asyncprawcore/auth.py @@ -129,7 +129,7 @@ async def revoke_token(self, token: str, token_type: str | None = None): await self._post(url, **data) -class BaseAuthorizer(ABC): +class BaseAuthorizer: """Superclass for OAuth2 authorization tokens and scopes.""" AUTHENTICATOR_CLASS: tuple | type = BaseAuthenticator diff --git a/pyproject.toml b/pyproject.toml index c4cb3e7..2e4b55f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -74,6 +74,8 @@ target-version = "py38" include = [ "asyncprawcore/*.py" ] + +[tool.ruff.lint] ignore = [ "A002", # shadowing built-in "ANN101", # missing type annotation for self in method @@ -128,13 +130,12 @@ select = [ "W", # pycodestyle warnings "UP" # pyupgrade ] -ignore-init-module-imports = true -[tool.ruff.flake8-annotations] +[tool.ruff.lint.flake8-annotations] allow-star-arg-any = true mypy-init-return = true suppress-dummy-args = true suppress-none-returning = true -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"]