Skip to content

Commit ca029c4

Browse files
committed
Add lint front + rollback back lint
1 parent 42f8f42 commit ca029c4

28 files changed

+2952
-3107
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "github-actions"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/lint.yml

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,36 @@ jobs:
66
backend:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v3
9+
- uses: actions/checkout@v5
1010
with:
1111
fetch-depth: 0
12-
line-length: 99
12+
13+
- name: Backend code formatting check (Black)
14+
uses: psf/black@stable
15+
with:
16+
use_pyproject: true
17+
18+
frontend:
19+
runs-on: ubuntu-latest
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v5
24+
uses: actions/setup-node@v5
25+
with:
26+
node-version: '14'
27+
# node-version-file: './atlas/static/.nvmrc'
28+
# cache: 'npm'
29+
# cache-dependency-path: './atlas/static/package-lock.json'
30+
31+
- name: Install dependencies
32+
run: ls -la
33+
# working-directory: atlas
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
working-directory: ./atlas/static
38+
39+
- name: Run check with ESLint
40+
run: npm run lint
41+
working-directory: ./atlas/static

atlas/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def inject_context():
7575
translations=get_tranlated_labels(),
7676
now=now,
7777
timedelta=timedelta,
78-
page_name=request.endpoint.split(".")[1]
78+
page_name=request.endpoint.split(".")[1],
7979
)
8080

8181
@app.template_filter("pretty")

atlas/atlasAPI.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def getObservationsPointAPI():
110110
)
111111
return jsonify(observations)
112112

113+
113114
@api.route("/taxonList", methods=["GET"])
114115
@api.route("/taxonList/area/<id_area>", methods=["GET"])
115116
@api.route("/taxonList/liste/<cd_ref>", methods=["GET"])

atlas/atlasRoutes.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,7 @@ def index():
115115
listTaxons = []
116116
if current_app.config["AFFICHAGE_TERRITOIRE_OBS"]:
117117
nb_taxons = vmTaxonsRepository.get_nb_taxons()
118-
listTaxons = vmTaxonsRepository.getListTaxon(
119-
params={
120-
"page": 0
121-
}
122-
)
123-
118+
listTaxons = vmTaxonsRepository.getListTaxon(params={"page": 0})
124119

125120
# si AFFICHAGE_TERRITOIRE_OBS on charge les données en AJAX
126121
# si AFFICHAGE_DERNIERES_OBS = False, on ne charge pas les obs
@@ -136,14 +131,14 @@ def index():
136131
observations = vmObservationsRepository.getObservationsChilds(
137132
params={
138133
"last_obs": str(current_app.config["NB_DAY_LAST_OBS"]) + " day",
139-
"fields": "taxons,medias"
134+
"fields": "taxons,medias",
140135
},
141136
)
142137
if current_app.config["AFFICHAGE_MAILLE"]:
143138
observations_mailles = vmObservationsMaillesRepository.getObservationsMaillesChilds(
144139
params={
145140
"last_obs": str(current_app.config["NB_DAY_LAST_OBS"]) + " day",
146-
"fields": "taxons,ids_obs"
141+
"fields": "taxons,ids_obs",
147142
}
148143
)
149144

@@ -180,7 +175,7 @@ def index():
180175
personal_data=personal_data,
181176
group2_inpn=group2_inpn,
182177
listTaxons=listTaxons,
183-
nb_taxons=nb_taxons
178+
nb_taxons=nb_taxons,
184179
)
185180

186181

@@ -318,12 +313,7 @@ def is_statut_in_groupe(statut, groupe):
318313
def area(id_area):
319314
area = vmAreasRepository.getAreaFromIdArea(id_area)
320315
stats_area = vmAreasRepository.getStatsByArea(id_area)
321-
listTaxons = vmTaxonsRepository.getListTaxon(
322-
id_area=id_area,
323-
params=MultiDict({
324-
"page": 0
325-
})
326-
)
316+
listTaxons = vmTaxonsRepository.getListTaxon(id_area=id_area, params=MultiDict({"page": 0}))
327317
group2_inpn = vmTaxonsRepository.get_group_inpn("group2_inpn", id_area)
328318
return render_template(
329319
"templates/areaSheet/_main.html",
@@ -332,7 +322,7 @@ def area(id_area):
332322
areaInfos=area,
333323
id_area=id_area,
334324
listTaxons=listTaxons,
335-
group2_inpn=group2_inpn
325+
group2_inpn=group2_inpn,
336326
)
337327

338328

@@ -343,12 +333,7 @@ def ficheRangTaxonomie(cd_ref=None):
343333
referenciel = vmTaxrefRepository.getInfoFromCd_ref(cd_ref)
344334
taxonomyHierarchy = vmTaxrefRepository.getAllTaxonomy(cd_ref)
345335
observers = vmObservationsRepository.getObservers(cd_ref)
346-
listTaxons = vmTaxonsRepository.getListTaxon(
347-
cd_ref=cd_ref,
348-
params=MultiDict({
349-
"page": 0
350-
})
351-
)
336+
listTaxons = vmTaxonsRepository.getListTaxon(cd_ref=cd_ref, params=MultiDict({"page": 0}))
352337

353338
return render_template(
354339
"templates/taxoRankSheet/_main.html",
@@ -357,7 +342,7 @@ def ficheRangTaxonomie(cd_ref=None):
357342
referenciel=referenciel,
358343
taxonomyHierarchy=taxonomyHierarchy,
359344
observers=observers,
360-
cd_ref=cd_ref
345+
cd_ref=cd_ref,
361346
)
362347

363348

@@ -367,12 +352,7 @@ def ficheGroupe(groupe):
367352
groups = vmTaxonsRepository.getAllINPNgroup()
368353
nb_taxons = vmTaxonsRepository.get_nb_taxons(group_name=groupe)
369354
observers = vmObservationsRepository.getGroupeObservers(groupe)
370-
listTaxons = vmTaxonsRepository.getListTaxon(
371-
group_name=groupe,
372-
params=MultiDict({
373-
"page": 0
374-
})
375-
)
355+
listTaxons = vmTaxonsRepository.getListTaxon(group_name=groupe, params=MultiDict({"page": 0}))
376356

377357
return render_template(
378358
"templates/groupSheet/_main.html",

atlas/configuration/config_schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class MapConfig(Schema):
127127
load_default={"fill": False, "fillColor": "#020202", "fillOpacity": 0.7}
128128
)
129129

130+
130131
class CouchesSigConfig(Schema):
131132
name = fields.Str(required=True)
132133
type = fields.Str(required=True, validate=validate.OneOf(["wms", "geojson"]))
@@ -139,7 +140,9 @@ class CouchesSigConfig(Schema):
139140

140141
@validates_schema
141142
def layer_required_for_wms_type(self, data, **kwargs):
142-
if data["type"] == "wms" and (not data.get("options").get("layers") or not data.get("options").get("wms_version")):
143+
if data["type"] == "wms" and (
144+
not data.get("options").get("layers") or not data.get("options").get("wms_version")
145+
):
143146
raise ValidationError("'layers' and 'wms_version' are required for type 'wms'")
144147

145148

atlas/modeles/entities/vmMedias.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ class VmMedias(db.Model):
2121
id_type: Mapped[int] = mapped_column()
2222
licence: Mapped[str] = mapped_column(String(100))
2323
source: Mapped[str] = mapped_column(String(25))
24-

atlas/modeles/entities/vmTaxons.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ class VmTaxons(db.Model):
4646
main_media: Mapped[VmMedias] = relationship(
4747
VmMedias,
4848
primaryjoin=and_(
49-
VmMedias.cd_ref == cd_ref,
50-
VmMedias.id_type == current_app.config["ATTR_MAIN_PHOTO"]
49+
VmMedias.cd_ref == cd_ref, VmMedias.id_type == current_app.config["ATTR_MAIN_PHOTO"]
5150
),
5251
)
52+
5353
def as_dict(self, with_main_media=False):
5454
d = {
5555
"cd_ref": self.cd_ref,
@@ -63,13 +63,13 @@ def as_dict(self, with_main_media=False):
6363
"yearmax": self.yearmax,
6464
"nb_obs": self.nb_obs,
6565
"group2_inpn": utils.deleteAccent(self.group2_inpn),
66-
"group3_inpn": utils.deleteAccent(self.group3_inpn)
66+
"group3_inpn": utils.deleteAccent(self.group3_inpn),
6767
}
6868
if with_main_media:
6969
d["media"] = self.get_main_media()
7070
return d
7171

72-
def get_main_media(self, size=(80,80)):
72+
def get_main_media(self, size=(80, 80)):
7373
"""Get main image of default logo
7474
7575
Parameters
@@ -83,14 +83,14 @@ def get_main_media(self, size=(80,80)):
8383
The path or url of the main image if exist, the logo of the group INPN if not
8484
"""
8585
default_media = url_for(
86-
'static',
87-
filename=f"images/picto_{utils.deleteAccent(self.group2_inpn).replace(' ', '_') }.png"
86+
"static",
87+
filename=f"images/picto_{utils.deleteAccent(self.group2_inpn).replace(' ', '_') }.png",
8888
)
8989
if self.main_media:
9090
if current_app.config["REDIMENSIONNEMENT_IMAGE"]:
9191
height, width = size
9292
return urljoin(
93-
current_app.config['TAXHUB_URL'],
93+
current_app.config["TAXHUB_URL"],
9494
f"api/tmedias/thumbnail/{self.main_media.id_media}?h={height}&width={width}",
9595
)
9696
else:
@@ -103,7 +103,6 @@ def get_main_media(self, size=(80,80)):
103103
else:
104104
return default_media
105105

106-
107106
def shorten_name(self):
108107
shorten_nom_vern = self.nom_vern.split(",")[0] if self.nom_vern else ""
109108
return shorten_nom_vern + " | <i>" + self.lb_nom + " </i>"

atlas/modeles/repositories/vmAreasRepository.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,22 @@ def getAreaFromIdArea(id_area):
6565
area_dict = {
6666
"areaName": area.area_name,
6767
"areaID": str(area.id_area),
68-
"areaCode" : str(area.area_code),
68+
"areaCode": str(area.area_code),
6969
"areaGeoJson": ast.literal_eval(area.area_geojson),
7070
"typeName": area.type_name,
7171
"description": area.description,
7272
"areasParent": [],
7373
}
7474

7575
subquery = (
76-
db.session.query(VmCorAreas.id_area_parent).filter(VmCorAreas.id_area == id_area).subquery()
76+
db.session.query(VmCorAreas.id_area_parent)
77+
.filter(VmCorAreas.id_area == id_area)
78+
.subquery()
7779
)
7880

7981
areas_parent = (
8082
db.session.query(
81-
VmAreas.area_name,
82-
VmAreas.id_area,
83-
VmAreas.area_code,
84-
VmBibAreasTypes.type_name
83+
VmAreas.area_name, VmAreas.id_area, VmAreas.area_code, VmBibAreasTypes.type_name
8584
)
8685
.join(subquery, subquery.c.id_area_parent == VmAreas.id_area)
8786
.join(VmBibAreasTypes, VmBibAreasTypes.id_type == VmAreas.id_type)

atlas/modeles/repositories/vmObservationsMaillesRepository.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def getObservationsMaillesChilds(params={}):
3737
- last_obs_year : l'année à laquel la dernière observation a été faite dans la maille
3838
- obs_nbr : le nombre d'observation dans la maille
3939
- taxons (optionnel: si fields=taxons) : une liste des taxons dans la maille
40-
- ids_obs (optionnel si fields=ids_obs): la liste des id_observations de la maille
40+
- ids_obs (optionnel si fields=ids_obs): la liste des id_observations de la maille
4141
Parameters
4242
----------
4343
filters : dict, optional
@@ -70,7 +70,7 @@ def getObservationsMaillesChilds(params={}):
7070
VmAreas.area_geojson,
7171
VMCorMailleObservation.type_code,
7272
func.max(func.date_part("year", VmObservations.dateobs)).label("last_obs_year"),
73-
func.count(VmObservations.id_observation).label("obs_nbr")
73+
func.count(VmObservations.id_observation).label("obs_nbr"),
7474
]
7575
if "taxons" in fields:
7676
query_select.append(
@@ -90,9 +90,7 @@ def getObservationsMaillesChilds(params={}):
9090
).label("taxons"),
9191
)
9292
if "ids_obs" in fields:
93-
query_select.append(
94-
func.array_agg(VmObservations.id_observation).label("ids_obs")
95-
)
93+
query_select.append(func.array_agg(VmObservations.id_observation).label("ids_obs"))
9694
query = (
9795
select(*query_select)
9896
.select_from(VmObservations)
@@ -144,10 +142,9 @@ def getObservationsMaillesChilds(params={}):
144142
"nb_observations": int(o.obs_nbr),
145143
"last_observation": o.last_obs_year,
146144
"taxons": o.taxons if "taxons" in fields else None,
147-
"ids_obs": o.ids_obs if "ids_obs" in fields else None
145+
"ids_obs": o.ids_obs if "ids_obs" in fields else None,
148146
},
149147
)
150148
for o in db.session.execute(query).all()
151149
]
152150
)
153-

0 commit comments

Comments
 (0)