fix lint checks

This commit is contained in:
Cayo Puigdefabregas 2023-03-27 10:55:26 +02:00
parent e6f91db4e4
commit e6c07851d4
7 changed files with 22 additions and 29 deletions

View File

@ -192,7 +192,7 @@ class Line(tqdm):
def error_message(self, *args): def error_message(self, *args):
self._error_message = args self._error_message = args
def close(self): def close(self): # noqa: C901
""" """
Cleanup and (if leave=False) close the progressbar. Cleanup and (if leave=False) close the progressbar.
""" """

View File

@ -1,6 +1,6 @@
import subprocess import subprocess
from contextlib import suppress from contextlib import suppress
from typing import Any, Set, TextIO from typing import Any, Set
from ereuse_devicehub.ereuse_utils import text from ereuse_devicehub.ereuse_utils import text
@ -96,9 +96,7 @@ class ProgressiveCmd:
self.conn = conn = subprocess.Popen( self.conn = conn = subprocess.Popen(
self.cmd, universal_newlines=True, stderr=subprocess.PIPE, stdout=stdout self.cmd, universal_newlines=True, stderr=subprocess.PIPE, stdout=stdout
) )
self.out = ( self.out = conn.stdout if stdout == subprocess.PIPE else conn.stderr
conn.stdout if stdout == subprocess.PIPE else conn.stderr
) # type: TextIO
self._callback = callback self._callback = callback
self.last_update_percentage = 0 self.last_update_percentage = 0
self.percentage = 0 self.percentage = 0

View File

@ -1,6 +1,3 @@
from typing import Generator
class NestedLookup: class NestedLookup:
@staticmethod @staticmethod
def __new__(cls, document, references, operation): def __new__(cls, document, references, operation):
@ -38,7 +35,7 @@ class NestedLookup:
return key_value_containing_value return key_value_containing_value
@staticmethod @staticmethod
def _nested_lookup(document, references, operation): def _nested_lookup(document, references, operation): # noqa: C901
"""Lookup a key in a nested document, yield a value""" """Lookup a key in a nested document, yield a value"""
if isinstance(document, list): if isinstance(document, list):
for d in document: for d in document:

View File

@ -5,7 +5,7 @@ from usb import CLASS_MASS_STORAGE
from ereuse_devicehub.ereuse_utils.naming import Naming from ereuse_devicehub.ereuse_utils.naming import Naming
def plugged_usbs(multiple=True) -> map or dict: def plugged_usbs(multiple=True) -> map or dict: # noqa: C901
""" """
Gets the plugged-in USB Flash drives (pen-drives). Gets the plugged-in USB Flash drives (pen-drives).

View File

@ -1,7 +1,7 @@
import datetime import datetime
from functools import wraps from functools import wraps
from flask import Response, make_response from flask import make_response
def cache(expires: datetime.timedelta = None): def cache(expires: datetime.timedelta = None):
@ -18,7 +18,7 @@ def cache(expires: datetime.timedelta = None):
def cache_decorator(view): def cache_decorator(view):
@wraps(view) @wraps(view)
def cache_func(*args, **kwargs): def cache_func(*args, **kwargs):
r = make_response(view(*args, **kwargs)) # type: Response r = make_response(view(*args, **kwargs))
r.expires = datetime.datetime.now(datetime.timezone.utc) + expires r.expires = datetime.datetime.now(datetime.timezone.utc) + expires
r.cache_control.public = True r.cache_control.public = True
return r return r

View File

@ -1,5 +1,3 @@
from typing import Dict, Set, Type
from boltons.typeutils import issubclass from boltons.typeutils import issubclass
from ereuse_devicehub.teal.resource import Resource from ereuse_devicehub.teal.resource import Resource
@ -12,16 +10,16 @@ class Config:
Subclass and set here your config values. Subclass and set here your config values.
""" """
RESOURCE_DEFINITIONS = set() # type: Set[Type[Resource]] RESOURCE_DEFINITIONS = set()
""" """
A list of resource definitions to load. A list of resource definitions to load.
""" """
SQLALCHEMY_DATABASE_URI = None # type: str SQLALCHEMY_DATABASE_URI = None
""" """
The access to the main Database. The access to the main Database.
""" """
SQLALCHEMY_BINDS = {} # type: Dict[str, str] SQLALCHEMY_BINDS = {}
""" """
Optional extra databases. See `here <http://flask-sqlalchemy.pocoo.org Optional extra databases. See `here <http://flask-sqlalchemy.pocoo.org
/2.3/binds/#referring-to-binds>`_ how bind your models to different /2.3/binds/#referring-to-binds>`_ how bind your models to different

View File

@ -1,19 +1,19 @@
import inspect import inspect
from typing import Dict, Type from typing import Type
import click_spinner import click_spinner
import ereuse_devicehub.ereuse_utils
import flask_cors import flask_cors
from anytree import Node from anytree import Node
from apispec import APISpec from apispec import APISpec
from click import option from click import option
from ereuse_devicehub.ereuse_utils import ensure_utf8
from flask import Flask, jsonify from flask import Flask, jsonify
from flask.globals import _app_ctx_stack from flask.globals import _app_ctx_stack
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from marshmallow import ValidationError from marshmallow import ValidationError
from werkzeug.exceptions import HTTPException, UnprocessableEntity from werkzeug.exceptions import HTTPException, UnprocessableEntity
import ereuse_devicehub.ereuse_utils
from ereuse_devicehub.ereuse_utils import ensure_utf8
from ereuse_devicehub.teal.auth import Auth from ereuse_devicehub.teal.auth import Auth
from ereuse_devicehub.teal.cli import TealCliRunner from ereuse_devicehub.teal.cli import TealCliRunner
from ereuse_devicehub.teal.client import Client from ereuse_devicehub.teal.client import Client
@ -122,12 +122,12 @@ class Teal(Flask):
# noinspection PyAttributeOutsideInit # noinspection PyAttributeOutsideInit
def load_resources(self): def load_resources(self):
self.resources = {} # type: Dict[str, Resource] self.resources = {}
""" """
The resources definitions loaded on this App, referenced by their The resources definitions loaded on this App, referenced by their
type name. type name.
""" """
self.tree = {} # type: Dict[str, Node] self.tree = {}
""" """
A tree representing the hierarchy of the instances of A tree representing the hierarchy of the instances of
ResourceDefinitions. ResourceDefinitions use these nodes to ResourceDefinitions. ResourceDefinitions use these nodes to