Skip to content

Commit

Permalink
Merge pull request #103 from bento-platform/lint/black
Browse files Browse the repository at this point in the history
lint: set up black linter/formatter
  • Loading branch information
davidlougheed authored Apr 12, 2024
2 parents 33ed62a + a2fd735 commit ed265e6
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 121 deletions.
18 changes: 12 additions & 6 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ name: Lint
on:
push:
branches:
- master
- main
pull_request:
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.10" ]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
name: Set up Python
with:
python-version: "3.10"
- name: Install flake8
run: python -m pip install flake8
- name: Run linter
run: flake8 ./chord_drs ./tests --exclude=migrations
python-version: ${{ matrix.python-version }}
- name: Install poetry
run: pip install poetry
- name: Install dependencies
run: poetry install
- name: Lint
run: |
poetry run black --check ./chord_drs ./tests
15 changes: 10 additions & 5 deletions chord_drs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,36 +43,41 @@
drs_compat=True,
logger=application.logger,
authz=authz_middleware,
))
),
)
application.register_error_handler(
BadRequest,
flask_errors.flask_error_wrap(
flask_errors.flask_bad_request_error,
drs_compat=True,
authz=authz_middleware,
))
),
)
application.register_error_handler(
Forbidden,
flask_errors.flask_error_wrap(
flask_errors.flask_forbidden_error,
drs_compat=True,
authz=authz_middleware,
))
),
)
application.register_error_handler(
NotFound,
lambda e: flask_errors.flask_error_wrap(
flask_errors.flask_not_found_error,
str(e),
drs_compat=True,
authz=authz_middleware,
)(e))
)(e),
)
application.register_error_handler(
RequestedRangeNotSatisfiable,
flask_errors.flask_error_wrap(
flask_errors.flask_range_not_satisfiable_error,
drs_compat=True,
authz=authz_middleware,
))
),
)

# Attach the database to the application and run migrations if needed
db.init_app(application)
Expand Down
1 change: 1 addition & 0 deletions chord_drs/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class FakeBackend(Backend):
"""
For the tests
"""

def save(self, current_location: str, filename: str) -> str:
return current_location
1 change: 1 addition & 0 deletions chord_drs/backends/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class LocalBackend(Backend):
by this service. Lives on the current filesystem, in a directory
specified by the DATA var env, the default being in ~/chord_drs_data
"""

def __init__(self):
self.base_location = Path(current_app.config["SERVICE_DATA"])
# We can use mkdir, since resolve has been called in config.py
Expand Down
4 changes: 2 additions & 2 deletions chord_drs/backends/minio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
class MinioBackend(Backend):
def __init__(self, resource=None):
self.minio = resource or boto3.resource(
's3',
"s3",
endpoint_url=current_app.config["MINIO_URL"],
aws_access_key_id=current_app.config["MINIO_USERNAME"],
aws_secret_access_key=current_app.config["MINIO_PASSWORD"]
aws_secret_access_key=current_app.config["MINIO_PASSWORD"],
)

self.bucket = self.minio.Bucket(current_app.config["MINIO_BUCKET"])
Expand Down
6 changes: 2 additions & 4 deletions chord_drs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,8 @@ def _get_from_environ_or_fail(var: str) -> str:
# when deployed inside chord_singularity, DATABASE will be set
BASEDIR = os.environ.get("DATABASE", APP_DIR.parent)
SERVICE_DATA: str = str(
Path(os.environ.get("DATA", os.path.join(Path.home(), "chord_drs_data")))
.expanduser()
.absolute()
.resolve())
Path(os.environ.get("DATA", os.path.join(Path.home(), "chord_drs_data"))).expanduser().absolute().resolve()
)

# Authorization variables
AUTHZ_ENABLED = os.environ.get("AUTHZ_ENABLED", "true").strip().lower() in TRUTH_VALUES
Expand Down
Loading

0 comments on commit ed265e6

Please sign in to comment.