fix some warnings

This commit is contained in:
Kay0u 2021-12-30 14:39:38 +01:00
parent 29d0d0cfc1
commit be0006fdb9
No known key found for this signature in database
GPG key ID: AE1DCADB6415A156
3 changed files with 14 additions and 6 deletions

View file

@ -331,7 +331,7 @@ class ExtendedArgumentParser(argparse.ArgumentParser):
c.execute(namespace, v) c.execute(namespace, v)
try: try:
delattr(namespace, CALLBACKS_PROP) delattr(namespace, CALLBACKS_PROP)
except: except AttributeError:
pass pass
def _get_callbacks_queue(self, namespace, create=True): def _get_callbacks_queue(self, namespace, create=True):

View file

@ -237,6 +237,7 @@ class Session:
secret = random_ascii() secret = random_ascii()
actionsmap_name = None # This is later set to the actionsmap name actionsmap_name = None # This is later set to the actionsmap name
@staticmethod
def set_infos(infos): def set_infos(infos):
assert isinstance(infos, dict) assert isinstance(infos, dict)
@ -250,6 +251,7 @@ class Session:
# samesite="strict", # Bottle 0.12 doesn't support samesite, to be added in next versions # samesite="strict", # Bottle 0.12 doesn't support samesite, to be added in next versions
) )
@staticmethod
def get_infos(raise_if_no_session_exists=True): def get_infos(raise_if_no_session_exists=True):
try: try:
@ -673,13 +675,14 @@ class ActionsMapParser(BaseActionsMapParser):
return parser.authentication return parser.authentication
def parse_args(self, args, route, **kwargs): def parse_args(self, args, **kwargs):
"""Parse arguments """Parse arguments
Keyword arguments: Keyword arguments:
- route -- The action route as a 2-tuple (method, path) - route -- The action route as a 2-tuple (method, path)
""" """
route = kwargs["route"]
try: try:
# Retrieve the parser for the route # Retrieve the parser for the route
_, parser = self._parsers[route] _, parser = self._parsers[route]

View file

@ -1,5 +1,4 @@
import os import os
import logging
# import all constants because other modules try to import them from this # import all constants because other modules try to import them from this
# module because SUCCESS is defined in this module # module because SUCCESS is defined in this module
@ -70,8 +69,11 @@ def configure_logging(logging_config=None):
def getHandlersByClass(classinfo, limit=0): def getHandlersByClass(classinfo, limit=0):
"""Retrieve registered handlers of a given class.""" """Retrieve registered handlers of a given class."""
from logging import _handlers
handlers = [] handlers = []
for ref in logging._handlers.itervaluerefs(): for ref in _handlers.itervaluerefs():
o = ref() o = ref()
if o is not None and isinstance(o, classinfo): if o is not None and isinstance(o, classinfo):
if limit == 1: if limit == 1:
@ -102,14 +104,17 @@ class MoulinetteLogger(Logger):
def findCaller(self, *args): def findCaller(self, *args):
"""Override findCaller method to consider this source file.""" """Override findCaller method to consider this source file."""
f = logging.currentframe()
from logging import currentframe, _srcfile
f = currentframe()
if f is not None: if f is not None:
f = f.f_back f = f.f_back
rv = "(unknown file)", 0, "(unknown function)" rv = "(unknown file)", 0, "(unknown function)"
while hasattr(f, "f_code"): while hasattr(f, "f_code"):
co = f.f_code co = f.f_code
filename = os.path.normcase(co.co_filename) filename = os.path.normcase(co.co_filename)
if filename == logging._srcfile or filename == __file__: if filename == _srcfile or filename == __file__:
f = f.f_back f = f.f_back
continue continue
rv = (co.co_filename, f.f_lineno, co.co_name) rv = (co.co_filename, f.f_lineno, co.co_name)