Skip to content

Commit

Permalink
replace flake8 with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
jtherrmann committed Jan 2, 2025
1 parent 7c1530b commit 3ee1d1d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 18 deletions.
17 changes: 2 additions & 15 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,8 @@ on: push

jobs:

flake8:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: 3.12

- run: |
python -m pip install --upgrade pip
python -m pip install flake8 flake8-import-order flake8-blind-except flake8-builtins
- run: flake8 --max-line-length=120 --import-order-style=pycharm --statistics --application-import-names door
call-ruff-workflow:
uses: ASFHyP3/actions/.github/workflows/[email protected]

cfn-lint:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions Job or Workflow does not set permissions
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [PEP 440](https://www.python.org/dev/peps/pep-0440/)
and uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.0.3]
### Changed
- Replaced `flake8` with `ruff`.

## [1.0.2]
### Fixed
- Upgraded to flask-cors v5.0.0 from v4.0.1. Resolves [CVE-2024-6221](https://github.com/asfadmin/grfn-distribution/security/dependabot/6).
Expand Down
1 change: 1 addition & 0 deletions door/src/door/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask


app = Flask(__name__)

from door import routes # noqa Has to be at end of file or will cause circular import
Expand Down
3 changes: 2 additions & 1 deletion door/src/door/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from door import app

if __name__ == "__main__":

if __name__ == '__main__':
app.run(port=8080)
5 changes: 3 additions & 2 deletions door/src/door/routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from datetime import datetime, timedelta, timezone
from datetime import UTC, datetime, timedelta
from urllib.parse import quote_plus

import boto3
Expand All @@ -12,6 +12,7 @@

from door import app


CORS(app, origins=r'https?://([-\w]+\.)*asf\.alaska\.edu', supports_credentials=True)
s3 = boto3.client('s3')

Expand Down Expand Up @@ -60,7 +61,7 @@ def rsa_signer(message):
return rsa.sign(message, key, 'SHA-1')

base_url = f'https://{os.environ["CLOUDFRONT_DOMAIN_NAME"]}/{object_key}?userid={user_id}'
expiration_datetime = datetime.now(tz=timezone.utc) + timedelta(seconds=int(os.environ['EXPIRE_TIME_IN_SECONDS']))
expiration_datetime = datetime.now(tz=UTC) + timedelta(seconds=int(os.environ['EXPIRE_TIME_IN_SECONDS']))
cf_signer = CloudFrontSigner(os.environ['CLOUDFRONT_KEY_PAIR_ID'], rsa_signer)
signed_url = cf_signer.generate_presigned_url(base_url, date_less_than=expiration_datetime)
return signed_url
31 changes: 31 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[project]
requires-python = "==3.12"

[tool.ruff]
line-length = 120
# The directories to consider when resolving first- vs. third-party imports.
# See: https://docs.astral.sh/ruff/settings/#src
src = ["**/src"]

[tool.ruff.format]
indent-style = "space"
quote-style = "single"

[tool.ruff.lint]
extend-select = [
"I", # isort: https://docs.astral.sh/ruff/rules/#isort-i
"UP", # pyupgrade: https://docs.astral.sh/ruff/rules/#pyupgrade-up

# TODO: uncomment the following extensions and address their warnings:
#"D", # pydocstyle: https://docs.astral.sh/ruff/rules/#pydocstyle-d
#"ANN", # annotations: https://docs.astral.sh/ruff/rules/#flake8-annotations-ann

"PTH", # use-pathlib-pth: https://docs.astral.sh/ruff/rules/#flake8-use-pathlib-pth
]

[tool.ruff.lint.pydocstyle]
convention = "google"

[tool.ruff.lint.isort]
case-sensitive = true
lines-after-imports = 2

0 comments on commit 3ee1d1d

Please sign in to comment.