Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner committed Oct 11, 2024
1 parent 63cea32 commit dfeb170
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 45 deletions.
2 changes: 1 addition & 1 deletion custom/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ RUN --mount=type=cache,target=/var/lib/apt/lists \

ENV PATH=/venv/bin:$PATH

FROM base-all as poetry
FROM base-all AS poetry

WORKDIR /tmp
COPY requirements.txt ./
Expand Down
2 changes: 1 addition & 1 deletion custom/custom/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import c2cwsgiutils.db
import c2cwsgiutils.health_check
from pyramid.config import Configurator
from pyramid.config import Configurator # type: ignore[import-untyped]


def main(global_config, **settings):
Expand Down
2 changes: 1 addition & 1 deletion custom/custom/alembic/env.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Pyramid bootstrap environment. """

from alembic import context
from pyramid.paster import get_appsettings, setup_logging
from pyramid.paster import get_appsettings, setup_logging # type: ignore[import-untyped]
from sqlalchemy import engine_from_config

from custom.models.meta import Base
Expand Down
2 changes: 1 addition & 1 deletion custom/custom/scripts/initialize_db.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
import sys

from pyramid.paster import bootstrap, setup_logging
from pyramid.paster import bootstrap, setup_logging # type: ignore[import-untyped]
from sqlalchemy.exc import OperationalError

from custom.models.meta import Base
Expand Down
6 changes: 3 additions & 3 deletions custom/custom/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import os

import pyramid.request
import pyramid.response
from cornice import Service
import pyramid.request # type: ignore[import-untyped]
import pyramid.response # type: ignore[import-untyped]
from cornice import Service # type: ignore[import-untyped]

index = Service(
name="index",
Expand Down
10 changes: 5 additions & 5 deletions custom/custom/views/cog.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import logging
import os

import pyramid.request
import pyramid.response
import pyramid.request # type: ignore[import-untyped]
import pyramid.response # type: ignore[import-untyped]
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient, ContainerClient
from cornice import Service
from pyramid.httpexceptions import HTTPBadRequest
from cornice import Service # type: ignore[import-untyped]
from pyramid.httpexceptions import HTTPBadRequest # type: ignore[import-untyped]

_LOGGING = logging.getLogger(__name__)
_CLIENT = None
Expand Down Expand Up @@ -38,7 +38,7 @@ def _get_azure_container_client(container: str) -> ContainerClient:
@feedback.get()
def swissalti3d(request: pyramid.request.Request) -> pyramid.response.Response:
# Just to demonstrate that we can fet the user information
global _CLIENT
global _CLIENT # pylint: disable=global-statement
if _CLIENT is None:
_CLIENT = _get_azure_container_client(os.environ["AZURE_CONTAINER_NAME"])
blob = _CLIENT.get_blob_client(blob="swissalti3d_2m_archeo.tif")
Expand Down
20 changes: 10 additions & 10 deletions custom/custom/views/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
import os
from typing import Any

import pyramid.request
import pyramid.request # type: ignore[import-untyped]
import requests
from cornice import Service
from pyramid.httpexceptions import HTTPBadRequest
from cornice import Service # type: ignore[import-untyped]
from pyramid.httpexceptions import HTTPBadRequest # type: ignore[import-untyped]

from custom.models.feedback import Feedback
from custom.util.send_mail import send_mail
Expand All @@ -32,7 +32,7 @@ def feedback_post(request: pyramid.request.Request) -> Any:
headers={"Cookie": request.headers.get("Cookie"), "Referer": request.referrer},
).json()
)
except Exception:
except Exception: # pylint: disable=broad-exception-caught
LOG.exception("Error on get user information")

if (
Expand Down Expand Up @@ -64,12 +64,12 @@ def feedback_post(request: pyramid.request.Request) -> Any:
text = "\n\n".join(
[
"Ceci est un email automatique. Un nouveau feedback a été inséré dans la BD.",
"Cela concerne l'instance : " + instance,
"Son identifiant est le : " + str(new_feedback.id_feedback),
"User agent : " + new_feedback.ua,
"Permalink : " + new_feedback.permalink,
"User email : " + new_feedback.email,
"User text : " + new_feedback.text,
"Cela concerne l'instance: " + instance,
"Son identifiant est le: " + str(new_feedback.id_feedback),
"User agent: " + new_feedback.ua, # type: ignore[list-item]
"Permalink: " + new_feedback.permalink, # type: ignore[list-item]
"User email: " + new_feedback.email, # type: ignore[list-item]
"User text: " + new_feedback.text, # type: ignore[list-item]
]
)
subject = "Feedback - Guichet cartographique"
Expand Down
2 changes: 1 addition & 1 deletion custom/custom/views/notfound.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pyramid.view import notfound_view_config
from pyramid.view import notfound_view_config # type: ignore[import-untyped]


@notfound_view_config(renderer="custom:templates/404.mako")
Expand Down
8 changes: 4 additions & 4 deletions custom/gunicorn.conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

from c2cwsgiutils import get_config_defaults

bind = ":8080"
bind = ":8080" # pylint: disable=invalid-name

worker_class = "gthread"
worker_class = "gthread" # pylint: disable=invalid-name
workers = os.environ.get("GUNICORN_WORKERS", 2)
threads = os.environ.get("GUNICORN_THREADS", 10)

preload = "true"
preload = "true" # pylint: disable=invalid-name

accesslog = "-"
accesslog = "-" # pylint: disable=invalid-name
access_log_format = os.environ.get(
"GUNICORN_ACCESS_LOG_FORMAT",
'%(H)s %({Host}i)s %(m)s %(U)s?%(q)s "%(f)s" "%(a)s" %(s)s %(B)s %(D)s %(p)s',
Expand Down
16 changes: 15 additions & 1 deletion custom/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions custom/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ cryptography = "43.0.1"
prospector = { version = "1.12.0", extras = ["with_bandit", "with_mypy", "with_pyroma"] }
prospector-profile-utils = "1.9.1"
prospector-profile-duplicated = "1.6.0"
types-requests = "2.32.0.20240914"
17 changes: 0 additions & 17 deletions custom/setup.py

This file was deleted.

0 comments on commit dfeb170

Please sign in to comment.