Skip to content

Commit a27c00a

Browse files
authored
Merge pull request #11 from LEQO-Framework/fix/flake8-errors
[Linting] Remove pre-commit, adjust flake8 config, and fix F541 errors
2 parents e826b3b + 4c48ed9 commit a27c00a

File tree

27 files changed

+236
-227
lines changed

27 files changed

+236
-227
lines changed

.flake8

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ exclude =
77
build,
88
dist
99
max-line-length = 140
10-
max-doc-length = 80
11-
max-complexity = 10
10+
max-doc-length = 120
11+
max-complexity = 12
1212
docstring-convention=google
1313
select=C,E,F,W,B,B902
14-
extend-ignore = E203
14+
extend-ignore = E203, W503

.github/workflows/ci-cd.yml

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Push Docker Image
1+
name: Build and Publish BloqCat Docker Image
22

33
on:
44
push:
@@ -9,22 +9,35 @@ jobs:
99
build-and-push:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
# Step 1: Checkout the repository code
13+
- name: Checkout code
14+
uses: actions/checkout@v3
1315

14-
- name: Set up Docker Buildx
15-
uses: docker/setup-buildx-action@v1
16+
# Step 2: Set up Docker Buildx
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v2
1619

17-
- name: Log in to GitHub Container Registry
18-
uses: docker/login-action@v1
19-
with:
20-
registry: ghcr.io
21-
username: ${{ github.actor }}
22-
password: ${{ secrets.GHCR_PAT }}
20+
# Step 3: Log in to GHCR
21+
- name: Log in to GitHub Container Registry
22+
uses: docker/login-action@v2
23+
with:
24+
registry: ghcr.io
25+
username: ${{ github.actor }}
26+
password: ${{ secrets.GITHUB_TOKEN }}
2327

24-
- name: Build and push
25-
uses: docker/build-push-action@v2
26-
with:
27-
context: .
28-
file: ./Dockerfile
29-
push: true
30-
tags: ghcr.io/aldekal/bloqcat:latest
28+
# Step 4: Build and push the Docker image
29+
- name: Build and push Docker image
30+
uses: docker/build-push-action@v2
31+
with:
32+
context: .
33+
file: ./Dockerfile
34+
push: true
35+
tags: ghcr.io/${{ github.repository_owner }}/bloqcat:latest
36+
37+
# Step 5: Make the image public
38+
- name: Set public visibility for GHCR image
39+
run: |
40+
gh api -X PATCH \
41+
/user/packages/container/bloqcat/visibility \
42+
-F visibility=public \
43+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"

.github/workflows/lint_format.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Formatting and linting
2+
3+
on: [push]
4+
5+
jobs:
6+
check-formatting-and-linting:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout
10+
uses: actions/checkout@v3
11+
- name: Setup python
12+
uses: actions/setup-python@v4
13+
with:
14+
python-version: 3.11.0
15+
- name: Install black and flake8
16+
run: python -m pip install black flake8
17+
- name: Run flake8
18+
run: flake8
19+
- name: Run black
20+
run: black --check --verbose --extend-exclude=".resources." .

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ FROM python:3.9-slim
55
WORKDIR /app
66

77
# Copy the pyproject.toml and poetry.lock files to the container
8-
COPY pyproject.toml poetry.lock /app/
8+
COPY pyproject.toml poetry.lock README.md /app/
9+
COPY bloqcat /app/bloqcat
910

1011
ENV PATH="/root/.local/bin:${PATH}"
1112

bloqcat/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,3 @@ def create_app(test_config: Optional[Dict[str, Any]] = None):
133133
@click.group(cls=FlaskGroup, create_app=create_app)
134134
def cli():
135135
"""Cli entry point for autodoc tooling."""
136-
pass

bloqcat/api/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ class VersionsRootSchema(MaBaseSchema):
3232
class RootView(MethodView):
3333
@ROOT_ENDPOINT.response(HTTPStatus.OK, VersionsRootSchema())
3434
def get(self) -> Dict[str, str]:
35-
"""Get the Root API information containing the links to all versions of this api."""
35+
"""Get the Root API information containing the links to all versions of this
36+
api."""
3637
return {
3738
"title": ROOT_API.spec.title,
3839
"v1": url_for("api-v1.RootView", _external=True),

bloqcat/api/jwt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545

4646
class JWTMixin:
47-
"""Extend Blueprint to add security documentation and jwt handling"""
47+
"""Extend Blueprint to add security documentation and jwt handling."""
4848

4949
def require_jwt(
5050
self,
@@ -54,12 +54,12 @@ def require_jwt(
5454
optional: bool = False,
5555
refresh_token: bool = False,
5656
) -> Callable[[Callable[..., RT]], Callable[..., RT]]:
57-
"""Decorator validating jwt tokens and documenting them for openapi specification (only version 3...)."""
57+
"""Decorator validating jwt tokens and documenting them for openapi specification
58+
(only version 3...)."""
5859
if isinstance(security_scheme, str):
5960
security_scheme = {security_scheme: []}
6061

6162
def decorator(func: Callable[..., RT]) -> Callable[..., RT]:
62-
6363
# map to names that are less likely to have collisions with user defined arguments!
6464
_jwt_optional = optional
6565
_jwt_fresh = fresh

bloqcat/api/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Module containing utilities for flask smorest APIs."""
2+
23
from typing import Any
34
from .jwt import JWTMixin
45
from flask_smorest import Blueprint

bloqcat/api/v1_api/auth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ class LoginView(MethodView):
6262
def post(self, credentials: Dict[str, str]):
6363
"""Login with the user credentials to receive a access and refresh token pair.
6464
65-
The access token can be used for all authorized api endpoints.
66-
The refresh token can only be used with the refresh endpoint to get a new access token.
65+
The access token can be used for all authorized api endpoints. The refresh token
66+
can only be used with the refresh endpoint to get a new access token.
6767
"""
6868
identity = DemoUser(credentials.get("username", "guest"))
6969
return LoginTokensData(

0 commit comments

Comments
 (0)