From b1fa9b8ef84825caa28eae151f1e0cd9ae961c63 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Mon, 27 Sep 2021 13:43:11 +0200 Subject: [PATCH] small fixes --- app/__init__.py | 5 +++-- app/models/departements.py | 5 +---- app/scodoc/sco_formsemestre_status.py | 4 +++- app/scodoc/sco_inscr_passage.py | 4 +++- app/scodoc/sco_synchro_etuds.py | 2 +- pylintrc | 16 ++++++++++++++++ 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index a63f9a23c..3187ea7af 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -2,7 +2,7 @@ # pylint: disable=invalid-name import os -import re +import reprlib import socket import sys import time @@ -112,7 +112,8 @@ class LogExceptionFormatter(logging.Formatter): if request.method == "GET": record.http_params = str(request.args) else: - record.http_params = "(post data not loggued)" + rep = reprlib.Repr() # abbrège + record.http_params = str(rep.repr(request.form)) else: record.url = None record.remote_addr = None diff --git a/app/models/departements.py b/app/models/departements.py index 32cb86374..36aa8d4c6 100644 --- a/app/models/departements.py +++ b/app/models/departements.py @@ -33,7 +33,7 @@ class Departement(db.Model): semsets = db.relationship("NotesSemSet", lazy="dynamic", backref="departement") def __repr__(self): - return f"" + return f"<{self.__class__.__name__}(id={self.id}, acronym='{self.acronym}')>" def to_dict(self): data = { @@ -44,6 +44,3 @@ class Departement(db.Model): "date_creation": self.date_creation, } return data - - def __repr__(self): - return f"<{self.__class__.__name__}(id={self.id}, acronym='{self.acronym}')>" diff --git a/app/scodoc/sco_formsemestre_status.py b/app/scodoc/sco_formsemestre_status.py index ab850d531..e85fd4a3d 100644 --- a/app/scodoc/sco_formsemestre_status.py +++ b/app/scodoc/sco_formsemestre_status.py @@ -447,6 +447,7 @@ def retreive_formsemestre_from_request() -> int: args = request.form else: return None + formsemestre_id = None # Search formsemestre group_ids = args.get("group_ids", []) if "formsemestre_id" in args: @@ -479,7 +480,8 @@ def retreive_formsemestre_from_request() -> int: elif "partition_id" in args: partition = sco_groups.get_partition(args["partition_id"]) formsemestre_id = partition["formsemestre_id"] - else: + + if not formsemestre_id: return None # no current formsemestre return int(formsemestre_id) diff --git a/app/scodoc/sco_inscr_passage.py b/app/scodoc/sco_inscr_passage.py index bbd6f96df..22624f7b3 100644 --- a/app/scodoc/sco_inscr_passage.py +++ b/app/scodoc/sco_inscr_passage.py @@ -287,8 +287,10 @@ def formsemestre_inscr_passage( header = html_sco_header.sco_header(page_title="Passage des étudiants") footer = html_sco_header.sco_footer() H = [header] - if type(etuds) == type(""): + if isinstance(etuds, str): etuds = etuds.split(",") # vient du form de confirmation + elif isinstance(etuds, int): + etuds = [etuds] auth_etuds_by_sem, inscrits, candidats = list_authorized_etuds_by_sem(sem) etuds_set = set(etuds) diff --git a/app/scodoc/sco_synchro_etuds.py b/app/scodoc/sco_synchro_etuds.py index 73f0e4bf3..649358a6d 100644 --- a/app/scodoc/sco_synchro_etuds.py +++ b/app/scodoc/sco_synchro_etuds.py @@ -132,7 +132,7 @@ def formsemestre_synchro_etuds( inscrits_without_key = inscrits_without_key.split(",") elif not isinstance(inscrits_without_key, list): raise ValueError("invalid type for inscrits_without_key") - inscrits_without_key = [int(x) for x in inscrits_without_key] + inscrits_without_key = [int(x) for x in inscrits_without_key if x] ( etuds_by_cat, a_importer, diff --git a/pylintrc b/pylintrc index 1914493ef..057a85cd0 100644 --- a/pylintrc +++ b/pylintrc @@ -3,3 +3,19 @@ # List of plugins (as comma separated values of python module names) to load, # usually to register additional checkers. load-plugins=pylint_flask_sqlalchemy, pylint_flask + +[TYPECHECK] +# List of class names for which member attributes should not be checked (useful +# for classes with dynamically set attributes). This supports the use of +# qualified names. +ignored-classes=Permission, + SQLObject, + Registrant, + scoped_session, + func + +# List of module names for which member attributes should not be checked +# (useful for modules/projects where namespaces are manipulated during runtime +# and thus existing member attributes cannot be deduced by static analysis). It +# supports qualified module names, as well as Unix pattern matching. +ignored-modules=entreprises