Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrunner authored and renovate[bot] committed Nov 5, 2024
1 parent 80e3d51 commit 528d157
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/dimension_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from c2cgeoportal_admin.views.layers import LayerViews
from c2cgeoportal_commons.models.main import DimensionLayer

_list_field = partial(ListField, DimensionLayer) # type: ignore[var-annotated]
_list_field = partial(ListField, DimensionLayer)

_T = TypeVar("_T", bound=DimensionLayer)

Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/functionalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
from c2cgeoportal_admin.views.logged_views import LoggedViews
from c2cgeoportal_commons.models.main import Functionality

_list_field = partial(ListField, Functionality) # type: ignore[var-annotated]
_list_field = partial(ListField, Functionality)


def _translate_available_functionality(
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from c2cgeoportal_admin.views.logged_views import LoggedViews
from c2cgeoportal_commons.models.main import Interface

_list_field = partial(ListField, Interface) # type: ignore[var-annotated]
_list_field = partial(ListField, Interface)

base_schema = GeoFormSchemaNode(Interface)

Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/layer_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
from c2cgeoportal_admin.views.treeitems import TreeItemViews
from c2cgeoportal_commons.models.main import LayerGroup, TreeGroup

_list_field = partial(ListField, LayerGroup) # type: ignore[var-annotated]
_list_field = partial(ListField, LayerGroup)

base_schema = GeoFormSchemaNode(LayerGroup, widget=FormWidget(fields_template="layer_group_fields"))
base_schema.add(children_schema_node())
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from c2cgeoportal_admin.views.treeitems import TreeItemViews
from c2cgeoportal_commons.models.main import Interface, Layer

_list_field = partial(ListField, Layer) # type: ignore[var-annotated]
_list_field = partial(ListField, Layer)

_T = TypeVar("_T", bound=Layer)

Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/layers_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayerCOG, LayerGroup

_list_field = partial(ListField, LayerCOG) # type: ignore[var-annotated]
_list_field = partial(ListField, LayerCOG)


base_schema = GeoFormSchemaNode(LayerCOG, widget=FormWidget(fields_template="layer_fields"))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/layers_vectortiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayerGroup, LayerVectorTiles

_list_field = partial(ListField, LayerVectorTiles) # type: ignore[var-annotated]
_list_field = partial(ListField, LayerVectorTiles)


base_schema = GeoFormSchemaNode(LayerVectorTiles, widget=FormWidget(fields_template="layer_fields"))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/layers_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from c2cgeoportal_admin.views.dimension_layers import DimensionLayerViews
from c2cgeoportal_commons.models.main import LayerGroup, LayerWMS, LayerWMTS, LogAction, OGCServer, TreeItem

_list_field = partial(ListField, LayerWMS) # type: ignore[var-annotated]
_list_field = partial(ListField, LayerWMS)

base_schema = GeoFormSchemaNode(LayerWMS, widget=FormWidget(fields_template="layer_fields"))
base_schema.add(dimensions_schema_node(LayerWMS.dimensions))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/layers_wmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
from c2cgeoportal_admin.views.dimension_layers import DimensionLayerViews
from c2cgeoportal_commons.models.main import LayerGroup, LayerWMS, LayerWMTS, LogAction, OGCServer, TreeItem

_list_field = partial(ListField, LayerWMTS) # type: ignore[var-annotated]
_list_field = partial(ListField, LayerWMTS)

base_schema = GeoFormSchemaNode(LayerWMTS, widget=FormWidget(fields_template="layer_fields"))
base_schema.add(dimensions_schema_node(LayerWMTS.dimensions))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from c2cgeoportal_commons.models import _
from c2cgeoportal_commons.models.main import AbstractLog

_list_field = partial(ListField, AbstractLog) # type: ignore[var-annotated]
_list_field = partial(ListField, AbstractLog)


@view_defaults(match_param="table=logs")
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/oauth2_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from c2cgeoportal_admin.views.logged_views import LoggedViews
from c2cgeoportal_commons.models.static import Log, OAuth2Client

_list_field = partial(ListField, OAuth2Client) # type: ignore[var-annotated]
_list_field = partial(ListField, OAuth2Client)

base_schema = GeoFormSchemaNode(OAuth2Client)
base_schema.add_unique_validator(OAuth2Client.client_id, OAuth2Client.id)
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/ogc_servers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
from c2cgeoportal_commons.models import cache_invalidate_cb
from c2cgeoportal_commons.models.main import LogAction, OGCServer

_list_field = partial(ListField, OGCServer) # type: ignore[var-annotated]
_list_field = partial(ListField, OGCServer)

base_schema = GeoFormSchemaNode(OGCServer, widget=FormWidget(fields_template="ogcserver_fields"))
base_schema.add_unique_validator(OGCServer.name, OGCServer.id)
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/restriction_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
from c2cgeoportal_admin.widgets import ChildrenWidget, ChildWidget
from c2cgeoportal_commons.models.main import Layer, RestrictionArea

_list_field = partial(ListField, RestrictionArea) # type: ignore[var-annotated]
_list_field = partial(ListField, RestrictionArea)

base_schema = GeoFormSchemaNode(RestrictionArea, widget=FormWidget(fields_template="restriction_area_fields"))
base_schema.add_before("area", roles_schema_node(RestrictionArea.roles))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from c2cgeoportal_commons.models.main import Role
from c2cgeoportal_commons.models.static import User

_list_field = partial(ListField, Role) # type: ignore[var-annotated]
_list_field = partial(ListField, Role)

base_schema = GeoFormSchemaNode(Role, widget=FormWidget(fields_template="role_fields"))
base_schema.add_before("extent", functionalities_schema_node(Role.functionalities, Role))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
from c2cgeoportal_admin.views.treeitems import TreeItemViews
from c2cgeoportal_commons.models.main import Functionality, Interface, Role, Theme

_list_field = partial(ListField, Theme) # type: ignore[var-annotated]
_list_field = partial(ListField, Theme)

base_schema = GeoFormSchemaNode(Theme, widget=FormWidget(fields_template="theme_fields"))
base_schema.add(children_schema_node(only_groups=True))
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/treeitems.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from c2cgeoportal_admin.views.logged_views import LoggedViews
from c2cgeoportal_commons.models.main import LayergroupTreeitem, Metadata, TreeGroup, TreeItem

_list_field = partial(ListField, TreeItem) # type: ignore[var-annotated]
_list_field = partial(ListField, TreeItem)


_T = TypeVar("_T", bound=TreeItem)
Expand Down
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
from c2cgeoportal_commons.models.main import Role
from c2cgeoportal_commons.models.static import Log, User

_list_field = partial(ListField, User) # type: ignore[var-annotated]
_list_field = partial(ListField, User)

base_schema = GeoFormSchemaNode(User, widget=FormWidget(fields_template="user_fields"))
base_schema.add(roles_schema_node(User.roles))
Expand Down
2 changes: 1 addition & 1 deletion commons/c2cgeoportal_commons/models/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ class Shorturl(Base): # type: ignore
id: Mapped[int] = mapped_column(Integer, primary_key=True)
url: Mapped[str] = mapped_column(Unicode)
ref: Mapped[str] = mapped_column(String(20), index=True, unique=True, nullable=False)
creator_email: Mapped[str] = mapped_column(Unicode(200), nullable=True)
creator_email: Mapped[str | None] = mapped_column(Unicode(200), nullable=True)
creation: Mapped[datetime] = mapped_column(DateTime)
last_hit: Mapped[datetime] = mapped_column(DateTime, nullable=True)
nb_hits: Mapped[int] = mapped_column(Integer)
Expand Down
12 changes: 6 additions & 6 deletions geoportal/c2cgeoportal_geoportal/views/shortener.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
import random
import string
from datetime import datetime
from typing import cast
from urllib.parse import urlparse

import pyramid.request
from pyramid.httpexceptions import HTTPBadRequest, HTTPFound, HTTPInternalServerError, HTTPNotFound
from pyramid.view import view_config

from c2cgeoportal_commons.lib.email_ import send_email_config
from c2cgeoportal_commons.models import DBSession
from c2cgeoportal_commons.models.static import Shorturl
from c2cgeoportal_commons.models import DBSession, static
from c2cgeoportal_geoportal import is_allowed_url
from c2cgeoportal_geoportal.lib.common_headers import Cache, set_common_headers

Expand All @@ -60,7 +60,7 @@ def get(self) -> HTTPFound:
assert DBSession is not None

ref = self.request.matchdict["ref"]
short_urls = DBSession.query(Shorturl).filter(Shorturl.ref == ref).all()
short_urls = DBSession.query(static.Shorturl).filter(static.Shorturl.ref == ref).all()

if len(short_urls) != 1:
raise HTTPNotFound(f"Ref '{ref!s}' not found")
Expand Down Expand Up @@ -110,7 +110,7 @@ def create(self) -> dict[str, str]:
random.choice(string.ascii_letters + string.digits) # nosec
for i in range(self.settings.get("length", 4))
)
test_url = DBSession.query(Shorturl).filter(Shorturl.ref == ref).all()
test_url = DBSession.query(static.Shorturl).filter(static.Shorturl.ref == ref).all()
if not test_url:
break
tries += 1
Expand All @@ -119,10 +119,10 @@ def create(self) -> dict[str, str]:
logger.error(message)
raise HTTPInternalServerError(message)

user_email = self.request.user.email if self.request.user is not None else None
user_email = cast(static.User, self.request.user).email if self.request.user is not None else None
email = self.request.params.get("email")
if not shortened:
short_url = Shorturl()
short_url = static.Shorturl()
short_url.url = url
short_url.ref = ref
short_url.creator_email = user_email
Expand Down

0 comments on commit 528d157

Please sign in to comment.