diff --git a/.github/workflows/flake8.yml b/.github/workflows/flake8.yml deleted file mode 100644 index b70c68ba1..000000000 --- a/.github/workflows/flake8.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Flake8 - -on: - push: - pull_request: - -jobs: - flake8: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: 3.x - cache: pip - cache-dependency-path: requirements*.txt - - - name: Install pre-commit - run: | - python -m pip install --upgrade pip wheel - pip install -r requirements-dev.txt - - - name: Run flake8 - run: | - echo "::add-matcher::.github/matchers/flake8.json" - pre-commit run flake8 --all-files - echo "::remove-matcher owner=flake8::" diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 000000000..504e4008a --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -0,0 +1,29 @@ +name: pre-commit check + +on: + push: + pull_request: + +jobs: + pre-commit: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: 3.x + + - uses: astral-sh/setup-uv@v5 + + - name: pre-commit (uvx) + run: uvx pre-commit run --all + env: + RUFF_OUTPUT_FORMAT: github diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ba5025946..bc4fb63b6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,24 +9,12 @@ repos: - id: debug-statements - id: mixed-line-ending args: [--fix=lf] -- repo: https://github.com/pycqa/isort - rev: 5.13.2 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.8.6 hooks: - - id: isort - args: [--profile=black] -- repo: https://github.com/asottile/pyupgrade - rev: v3.19.1 - hooks: - - id: pyupgrade - args: [--py38-plus] -- repo: https://github.com/psf/black - rev: 24.10.0 - hooks: - - id: black -- repo: https://github.com/PyCQA/flake8 - rev: 7.1.1 - hooks: - - id: flake8 + - id: ruff + args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format - repo: meta hooks: - id: check-hooks-apply diff --git a/social_core/backends/keycloak.py b/social_core/backends/keycloak.py index 494ddabdb..8b87b5b3c 100644 --- a/social_core/backends/keycloak.py +++ b/social_core/backends/keycloak.py @@ -121,9 +121,7 @@ def public_key(self): ] ) - def user_data( - self, access_token, *args, **kwargs - ): # pylint: disable=unused-argument + def user_data(self, access_token, *args, **kwargs): # pylint: disable=unused-argument """Decode user data from the access_token You can specialize this method to e.g. get information diff --git a/social_core/backends/loginradius.py b/social_core/backends/loginradius.py index b7e5b3b12..fe9f0240a 100644 --- a/social_core/backends/loginradius.py +++ b/social_core/backends/loginradius.py @@ -37,7 +37,7 @@ def request_access_token(self, *args, **kwargs): return self.get_json( params={"token": self.data.get("token"), "secret": self.setting("SECRET")}, *args, - **kwargs + **kwargs, ) def user_data(self, access_token, *args, **kwargs): diff --git a/social_core/backends/orcid.py b/social_core/backends/orcid.py index 8717fc003..f1f35eae8 100644 --- a/social_core/backends/orcid.py +++ b/social_core/backends/orcid.py @@ -1,6 +1,6 @@ """ - ORCID OAuth2 Application backend, docs at: - https://python-social-auth.readthedocs.io/en/latest/backends/orcid.html +ORCID OAuth2 Application backend, docs at: +https://python-social-auth.readthedocs.io/en/latest/backends/orcid.html """ from .oauth import BaseOAuth2 diff --git a/social_core/backends/scistarter.py b/social_core/backends/scistarter.py index 8a4990d69..c6b91ac4a 100644 --- a/social_core/backends/scistarter.py +++ b/social_core/backends/scistarter.py @@ -1,4 +1,4 @@ -""" SciStarter OAuth2 Auth """ +"""SciStarter OAuth2 Auth""" from .oauth import BaseOAuth2 diff --git a/social_core/backends/untappd.py b/social_core/backends/untappd.py index 924a9d89e..0057a4a73 100644 --- a/social_core/backends/untappd.py +++ b/social_core/backends/untappd.py @@ -76,7 +76,7 @@ def auth_complete(self, *args, **kwargs): response["response"]["access_token"], response=response["response"], *args, - **kwargs + **kwargs, ) def get_user_details(self, response): diff --git a/social_core/backends/weibo.py b/social_core/backends/weibo.py index b69125d5e..eb0cc5a6a 100644 --- a/social_core/backends/weibo.py +++ b/social_core/backends/weibo.py @@ -3,6 +3,7 @@ Weibo OAuth2 backend, docs at: https://python-social-auth.readthedocs.io/en/latest/backends/weibo.html """ + from .oauth import BaseOAuth2 diff --git a/social_core/backends/weixin.py b/social_core/backends/weixin.py index 2aec528e2..b549b436b 100644 --- a/social_core/backends/weixin.py +++ b/social_core/backends/weixin.py @@ -2,6 +2,7 @@ """ Weixin OAuth2 backend """ + from urllib.parse import urlencode from requests import HTTPError diff --git a/social_core/pipeline/partial.py b/social_core/pipeline/partial.py index 8925ec699..661e63ae0 100644 --- a/social_core/pipeline/partial.py +++ b/social_core/pipeline/partial.py @@ -36,7 +36,7 @@ def wrapper(strategy, backend, pipeline_index, *args, **kwargs): pipeline_index=pipeline_index, current_partial=current_partial, *args, - **kwargs + **kwargs, ) or {} ) diff --git a/social_core/tests/backends/oauth.py b/social_core/tests/backends/oauth.py index f59a6f6ef..c4707f426 100644 --- a/social_core/tests/backends/oauth.py +++ b/social_core/tests/backends/oauth.py @@ -180,7 +180,6 @@ def do_login(self): class BaseAuthUrlTestMixin: - def check_parameters_in_authorization_url(self, auth_url_key="AUTHORIZATION_URL"): """ Check the parameters in authorization url diff --git a/social_core/tests/backends/test_keycloak.py b/social_core/tests/backends/test_keycloak.py index 9ef764f53..1d09d01d9 100644 --- a/social_core/tests/backends/test_keycloak.py +++ b/social_core/tests/backends/test_keycloak.py @@ -37,9 +37,7 @@ -----BEGIN RSA PRIVATE KEY----- {_PRIVATE_KEY_HEADERLESS} -----END RSA PRIVATE KEY----- -""".format( - _PRIVATE_KEY_HEADERLESS=_PRIVATE_KEY_HEADERLESS -) +""".format(_PRIVATE_KEY_HEADERLESS=_PRIVATE_KEY_HEADERLESS) _PUBLIC_KEY_HEADERLESS = """ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvyo2hx1L3ALHeUd/6xk/ @@ -55,9 +53,7 @@ -----BEGIN PUBLIC KEY----- {_PUBLIC_KEY_HEADERLESS} -----END PUBLIC KEY----- -""".format( - _PUBLIC_KEY_HEADERLESS=_PUBLIC_KEY_HEADERLESS -) +""".format(_PUBLIC_KEY_HEADERLESS=_PUBLIC_KEY_HEADERLESS) _KEY = "example" _SECRET = "1234abcd-1234-abcd-1234-abcd1234adcd"