mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Merge pull request #299 from YunoHost/mypy
tests: add mypy + misc fixes to make test pass
This commit is contained in:
commit
6a2ae5630b
6 changed files with 15 additions and 18 deletions
2
.github/workflows/tox.yml
vendored
2
.github/workflows/tox.yml
vendored
|
@ -44,3 +44,5 @@ jobs:
|
|||
pip install tox tox-gh-actions
|
||||
- name: Linter
|
||||
run: tox -e py37-invalidcode
|
||||
- name: Mypy
|
||||
run: tox -e py37-mypy
|
||||
|
|
|
@ -6,6 +6,7 @@ import logging
|
|||
import glob
|
||||
import pickle as pickle
|
||||
|
||||
from typing import List, Optional
|
||||
from time import time
|
||||
from collections import OrderedDict
|
||||
from importlib import import_module
|
||||
|
@ -30,7 +31,6 @@ logger = logging.getLogger("moulinette.actionsmap")
|
|||
|
||||
|
||||
class _ExtraParameter(object):
|
||||
|
||||
"""
|
||||
Argument parser for an extra parameter.
|
||||
|
||||
|
@ -39,21 +39,14 @@ class _ExtraParameter(object):
|
|||
|
||||
"""
|
||||
|
||||
name: Optional[str] = None
|
||||
|
||||
"""A list of interface for which the parameter doesn't apply to"""
|
||||
skipped_iface: List[str] = []
|
||||
|
||||
def __init__(self, iface):
|
||||
self.iface = iface
|
||||
|
||||
# Required variables
|
||||
# Each extra parameters classes must overwrite these variables.
|
||||
|
||||
"""The extra parameter name"""
|
||||
name = None
|
||||
|
||||
# Optional variables
|
||||
# Each extra parameters classes can overwrite these variables.
|
||||
|
||||
"""A list of interface for which the parameter doesn't apply"""
|
||||
skipped_iface = []
|
||||
|
||||
# Virtual methods
|
||||
# Each extra parameters classes can implement these methods.
|
||||
|
||||
|
@ -621,7 +614,7 @@ class ActionsMap(object):
|
|||
|
||||
# This var is ['*'] by default but could be set for example to
|
||||
# ['yunohost', 'yml_*']
|
||||
NAMESPACE_PATTERNS = env["NAMESPACES"]
|
||||
NAMESPACE_PATTERNS = env["NAMESPACES"].split()
|
||||
|
||||
# Look for all files that match the given patterns in the actionsmap dir
|
||||
for namespace_pattern in NAMESPACE_PATTERNS:
|
||||
|
|
|
@ -22,8 +22,6 @@ for key in env.keys():
|
|||
if value_from_environ:
|
||||
env[key] = value_from_environ
|
||||
|
||||
env["NAMESPACES"] = env["NAMESPACES"].split()
|
||||
|
||||
|
||||
def during_unittests_run():
|
||||
return "TESTS_RUN" in os.environ
|
||||
|
|
|
@ -7,6 +7,7 @@ import copy
|
|||
import datetime
|
||||
from collections import deque, OrderedDict
|
||||
from json.encoder import JSONEncoder
|
||||
from typing import Optional
|
||||
|
||||
from moulinette import m18n
|
||||
from moulinette.core import MoulinetteError
|
||||
|
@ -44,7 +45,7 @@ class BaseActionsMapParser(object):
|
|||
# Each parser classes must implement these properties.
|
||||
|
||||
"""The name of the interface for which it is the parser"""
|
||||
interface = None
|
||||
interface: Optional[str] = None
|
||||
|
||||
# Virtual methods
|
||||
# Each parser classes must implement these methods.
|
||||
|
|
|
@ -268,6 +268,7 @@ class Session:
|
|||
|
||||
return infos
|
||||
|
||||
@staticmethod
|
||||
def delete_infos():
|
||||
|
||||
response.set_cookie(f"session.{Session.actionsmap_name}", "", max_age=-1)
|
||||
|
|
4
tox.ini
4
tox.ini
|
@ -1,6 +1,6 @@
|
|||
[tox]
|
||||
envlist =
|
||||
py37-{pytest,lint,invalidcode}
|
||||
py37-{pytest,lint,invalidcode,mypy}
|
||||
format
|
||||
format-check
|
||||
docs
|
||||
|
@ -14,10 +14,12 @@ deps =
|
|||
py37-pytest: .[tests]
|
||||
py37-lint: flake8
|
||||
py37-invalidcode: flake8
|
||||
py37-mypy: mypy >= 0.761
|
||||
commands =
|
||||
py37-pytest: pytest {posargs} -c pytest.ini
|
||||
py37-lint: flake8 moulinette test
|
||||
py37-invalidcode: flake8 moulinette test --select F
|
||||
py37-mypy: mypy --ignore-missing-imports --install-types --non-interactive moulinette/
|
||||
|
||||
[gh-actions]
|
||||
python =
|
||||
|
|
Loading…
Reference in a new issue