Skip to content

Commit

Permalink
Apply pre-commit fix
Browse files Browse the repository at this point in the history
From the artifact of the previous workflow run
  • Loading branch information
geo-ghci-int[bot] committed Dec 3, 2024
1 parent 91f84f2 commit a560513
Show file tree
Hide file tree
Showing 85 changed files with 502 additions and 383 deletions.
4 changes: 3 additions & 1 deletion admin/c2cgeoportal_admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def get_tm_session(
)

# Add fake user as we do not have authentication from geoportal
from c2cgeoportal_commons.models.static import User # pylint: disable=import-outside-toplevel
from c2cgeoportal_commons.models.static import (
User, # pylint: disable=import-outside-toplevel
)

config.add_request_method(
lambda request: User(
Expand Down
13 changes: 6 additions & 7 deletions admin/c2cgeoportal_admin/lib/ogcserver_synchronizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@
import functools
import logging
from io import StringIO
from typing import Any, Optional, cast
from typing import Any, cast
from xml.etree.ElementTree import Element # nosec

import pyramid.request
import requests
from defusedxml import ElementTree
from sqlalchemy.orm.session import Session

from c2cgeoportal_commons.lib.url import get_url2
from c2cgeoportal_commons.models import main
from defusedxml import ElementTree
from sqlalchemy.orm.session import Session


class dry_run_transaction: # noqa ignore=N801: class names should use CapWords convention
Expand Down Expand Up @@ -238,7 +237,7 @@ def get_theme(self, el: ElementTree) -> main.Theme:
name = name_el.text

theme = cast(
Optional[main.Theme],
main.Theme | None,
self._request.dbsession.query(main.Theme).filter(main.Theme.name == name).one_or_none(),
)

Expand All @@ -263,7 +262,7 @@ def get_layer_group(self, el: Element, parent: main.TreeGroup) -> main.LayerGrou
assert name is not None

group = cast(
Optional[main.LayerGroup],
main.LayerGroup | None,
(
self._request.dbsession.query(main.LayerGroup)
.filter(main.LayerGroup.name == name)
Expand Down Expand Up @@ -294,7 +293,7 @@ def get_layer_wms(self, el: Element, parent: main.TreeGroup | None = None) -> ma
assert name is not None

layer = cast(
Optional[main.LayerWMS],
main.LayerWMS | None,
self._request.dbsession.query(main.LayerWMS).filter(main.LayerWMS.name == name).one_or_none(),
)

Expand Down
3 changes: 1 addition & 2 deletions admin/c2cgeoportal_admin/schemas/dimensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,10 @@

import colander
from c2cgeoform.schema import GeoFormSchemaNode
from c2cgeoportal_commons.models.main import Dimension
from deform.widget import MappingWidget, SequenceWidget
from sqlalchemy.orm.attributes import InstrumentedAttribute

from c2cgeoportal_commons.models.main import Dimension


def dimensions_schema_node(
prop: InstrumentedAttribute[Any], # pylint: disable=unsubscriptable-object
Expand Down
4 changes: 1 addition & 3 deletions admin/c2cgeoportal_admin/schemas/functionalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@
import colander
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
from c2cgeoportal_commons.models.main import Functionality
from sqlalchemy import inspect, select
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.sql.functions import concat

from c2cgeoportal_commons.models.main import Functionality


def available_functionalities_for(settings: dict[str, Any], model: type[Any]) -> list[dict[str, Any]]:
"""Return filtered list of functionality definitions."""
Expand Down Expand Up @@ -81,7 +80,6 @@ def functionalities_schema_node(
prop: InstrumentedAttribute[Any], model: type[Any]
) -> colander.SequenceSchema:
"""Get the schema of the functionalities."""

return colander.SequenceSchema(
GeoFormManyToManySchemaNode(Functionality, None),
name=prop.key,
Expand Down
3 changes: 1 addition & 2 deletions admin/c2cgeoportal_admin/schemas/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
import colander
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
from sqlalchemy.orm.attributes import InstrumentedAttribute

from c2cgeoportal_commons.models.main import Interface
from sqlalchemy.orm.attributes import InstrumentedAttribute


def interfaces_schema_node(
Expand Down
5 changes: 2 additions & 3 deletions admin/c2cgeoportal_admin/schemas/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
import colander
import pyramid.request
from c2cgeoform.schema import GeoFormSchemaNode
from c2cgeoportal_commons.lib.validators import url
from c2cgeoportal_commons.models.main import Metadata
from deform.widget import MappingWidget, SelectWidget, SequenceWidget, TextAreaWidget
from sqlalchemy import inspect
from sqlalchemy.orm.attributes import InstrumentedAttribute
from sqlalchemy.orm.mapper import Mapper

from c2cgeoportal_admin import _
from c2cgeoportal_commons.lib.validators import url
from c2cgeoportal_commons.models.main import Metadata


def get_relevant_for(model: type[Any] | Mapper[Any]) -> set[str]:
Expand Down Expand Up @@ -202,7 +202,6 @@ def _translate_available_metadata(

def metadata_schema_node(prop: InstrumentedAttribute[Any], model: type[Any]) -> colander.SequenceSchema:
"""Get the schema of a collection of metadata."""

# Deferred which returns a dictionary with metadata name as key and metadata definition as value.
# Needed to get the metadata types on UI side.
metadata_definitions_dict = colander.deferred(
Expand Down
3 changes: 1 addition & 2 deletions admin/c2cgeoportal_admin/schemas/restriction_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
import colander
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
from sqlalchemy.orm.attributes import InstrumentedAttribute

from c2cgeoportal_commons.models.main import RestrictionArea
from sqlalchemy.orm.attributes import InstrumentedAttribute


def restrictionareas_schema_node(
Expand Down
3 changes: 1 addition & 2 deletions admin/c2cgeoportal_admin/schemas/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@
import colander
from c2cgeoform.ext.deform_ext import RelationCheckBoxListWidget
from c2cgeoform.schema import GeoFormManyToManySchemaNode, manytomany_validator
from sqlalchemy.orm.attributes import InstrumentedAttribute

from c2cgeoportal_commons.models.main import Role
from sqlalchemy.orm.attributes import InstrumentedAttribute


def roles_schema_node(
Expand Down
9 changes: 5 additions & 4 deletions admin/c2cgeoportal_admin/schemas/treegroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
import pyramid.request
import sqlalchemy
from c2cgeoform.schema import GeoFormSchemaNode
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayergroupTreeitem, TreeGroup, TreeItem
from sqlalchemy.orm import aliased
from sqlalchemy.sql.expression import case, func

from c2cgeoportal_admin import _
from c2cgeoportal_admin.widgets import ChildrenWidget, ChildWidget
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayergroupTreeitem, TreeGroup, TreeItem

_LOG = logging.getLogger(__name__)

Expand Down Expand Up @@ -74,7 +74,8 @@ def treeitems(
assert isinstance(dbsession, sqlalchemy.orm.Session)

group = case(
(func.count(LayergroupTreeitem.id) == 0, "Unlinked"), else_="Others" # pylint: disable=not-callable
(func.count(LayergroupTreeitem.id) == 0, "Unlinked"),
else_="Others", # pylint: disable=not-callable
)

query = (
Expand Down Expand Up @@ -123,7 +124,7 @@ def treeitems(
def children_validator(node, cstruct):
"""Get the validator on the children nodes."""
for dict_ in cstruct:
if not dict_["treeitem_id"] in [item["id"] for item in node.candidates]:
if dict_["treeitem_id"] not in [item["id"] for item in node.candidates]:
raise colander.Invalid(
node,
_("Value {} does not exist in table {} or is not allowed to avoid cycles").format(
Expand Down
4 changes: 1 addition & 3 deletions admin/c2cgeoportal_admin/views/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@


class IsAdminPredicate:
"""
A custom predicate that checks if the request is for the admin interface.
"""
"""A custom predicate that checks if the request is for the admin interface."""

def __init__(self, val, info):
del info
Expand Down
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 @@ -32,10 +32,10 @@

import sqlalchemy.orm.query
from c2cgeoform.views.abstract_views import ListField
from c2cgeoportal_commons.models.main import DimensionLayer
from sqlalchemy.orm import subqueryload

from c2cgeoportal_admin.views.layers import LayerViews
from c2cgeoportal_commons.models.main import DimensionLayer

_list_field = partial(ListField, DimensionLayer)

Expand Down
6 changes: 4 additions & 2 deletions admin/c2cgeoportal_admin/views/functionalities.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.models.main import Functionality
from deform.widget import FormWidget
from pyramid.view import view_config, view_defaults

from c2cgeoportal_admin import _
from c2cgeoportal_admin.views.logged_views import LoggedViews
from c2cgeoportal_commons.models.main import Functionality

_list_field = partial(ListField, Functionality)

Expand Down Expand Up @@ -103,7 +103,9 @@ def delete(self) -> DeleteResponse:
return super().delete()

@view_config(
route_name="c2cgeoform_item_duplicate", request_method="GET", renderer="../templates/edit.jinja2" # type: ignore[misc]
route_name="c2cgeoform_item_duplicate",
request_method="GET",
renderer="../templates/edit.jinja2", # type: ignore[misc]
)
def duplicate(self) -> ObjectResponse:
return super().duplicate()
2 changes: 1 addition & 1 deletion admin/c2cgeoportal_admin/views/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.models.main import Interface
from pyramid.view import view_config, view_defaults

from c2cgeoportal_admin.views.logged_views import LoggedViews
from c2cgeoportal_commons.models.main import Interface

_list_field = partial(ListField, 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 @@ -39,14 +39,14 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.models.main import LayerGroup, TreeGroup
from deform.widget import FormWidget
from pyramid.view import view_config, view_defaults

from c2cgeoportal_admin.schemas.metadata import metadata_schema_node
from c2cgeoportal_admin.schemas.treegroup import children_schema_node
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
from c2cgeoportal_admin.views.treeitems import TreeItemViews
from c2cgeoportal_commons.models.main import LayerGroup, TreeGroup

_list_field = partial(ListField, LayerGroup)

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 @@ -32,10 +32,10 @@
import sqlalchemy
import sqlalchemy.orm.query
from c2cgeoform.views.abstract_views import ListField
from c2cgeoportal_commons.models.main import Interface, Layer
from sqlalchemy.orm import subqueryload

from c2cgeoportal_admin.views.treeitems import TreeItemViews
from c2cgeoportal_commons.models.main import Interface, Layer

_list_field = partial(ListField, Layer)

Expand Down
4 changes: 2 additions & 2 deletions admin/c2cgeoportal_admin/views/layers_cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayerCOG, LayerGroup
from deform.widget import FormWidget
from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config, view_defaults
Expand All @@ -50,8 +52,6 @@
from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
from c2cgeoportal_admin.views.layers import LayerViews
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayerCOG, LayerGroup

_list_field = partial(ListField, LayerCOG)

Expand Down
4 changes: 2 additions & 2 deletions admin/c2cgeoportal_admin/views/layers_vectortiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayerGroup, LayerVectorTiles
from deform.widget import FormWidget
from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config, view_defaults
Expand All @@ -50,8 +52,6 @@
from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
from c2cgeoportal_admin.views.dimension_layers import DimensionLayerViews
from c2cgeoportal_commons.lib.literal import Literal
from c2cgeoportal_commons.models.main import LayerGroup, LayerVectorTiles

_list_field = partial(ListField, LayerVectorTiles)

Expand Down
9 changes: 8 additions & 1 deletion admin/c2cgeoportal_admin/views/layers_wms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.models.main import (
LayerGroup,
LayerWMS,
LayerWMTS,
LogAction,
OGCServer,
TreeItem,
)
from deform.widget import FormWidget
from pyramid.view import view_config, view_defaults
from sqlalchemy import delete, insert, inspect, update
Expand All @@ -52,7 +60,6 @@
from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
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)

Expand Down
9 changes: 8 additions & 1 deletion admin/c2cgeoportal_admin/views/layers_wmts.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@
ObjectResponse,
SaveResponse,
)
from c2cgeoportal_commons.models.main import (
LayerGroup,
LayerWMS,
LayerWMTS,
LogAction,
OGCServer,
TreeItem,
)
from deform.widget import FormWidget
from pyramid.view import view_config, view_defaults
from sqlalchemy import delete, insert, inspect, update
Expand All @@ -52,7 +60,6 @@
from c2cgeoportal_admin.schemas.restriction_areas import restrictionareas_schema_node
from c2cgeoportal_admin.schemas.treeitem import parent_id_node
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)

Expand Down
8 changes: 7 additions & 1 deletion admin/c2cgeoportal_admin/views/layertree.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@

import pyramid.request
from c2cgeoform.views.abstract_views import DeleteResponse, ItemAction
from c2cgeoportal_commons.models.main import (
Interface,
Layer,
LayergroupTreeitem,
Theme,
TreeItem,
)
from pyramid.httpexceptions import HTTPNotFound
from pyramid.view import view_config, view_defaults
from translationstring import TranslationStringFactory

from c2cgeoportal_admin import _
from c2cgeoportal_commons.models.main import Interface, Layer, LayergroupTreeitem, Theme, TreeItem

itemtypes_tables = {
"theme": "themes",
Expand Down
3 changes: 1 addition & 2 deletions admin/c2cgeoportal_admin/views/logged_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
from typing import Generic, TypeVar

from c2cgeoform.views.abstract_views import AbstractViews, DeleteResponse, SaveResponse
from pyramid.httpexceptions import HTTPFound

from c2cgeoportal_commons.models import Base
from c2cgeoportal_commons.models.main import Log, LogAction
from pyramid.httpexceptions import HTTPFound

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

Expand Down
Loading

0 comments on commit a560513

Please sign in to comment.