mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
Fix Python errors reported by mypy
This commit fixes Python errors and warnings reported by static type checking with mypy. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
a9dd9c7d0d
commit
952bf4a4e1
9 changed files with 15 additions and 13 deletions
|
|
@ -14,7 +14,7 @@ jw-maintainer = jan
|
|||
libname = none
|
||||
|
||||
[pkg.requires.os]
|
||||
run = python3-magic, python3-termcolor
|
||||
run = python3-magic, python3-termcolor mypy
|
||||
|
||||
[pkg.requires.jw]
|
||||
devel = jw-python-run = VERSION-REVISION, jw-build-devel = VERSION
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
TOPDIR = ../..
|
||||
|
||||
include $(TOPDIR)/make/proj.mk
|
||||
include $(JWBDIR)/make/dirs.mk
|
||||
include $(JWBDIR)/make/py-mods.mk
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import abc
|
||||
import argparse
|
||||
from abc import ABC
|
||||
|
||||
from jwutils import log
|
||||
|
||||
# compatible with Python 2 *and* 3
|
||||
ABC = abc.ABCMeta('ABC', (object,), {'__slots__': ()})
|
||||
|
||||
# full blown example of one level of nested subcommands
|
||||
# git -C project remote -v show -n myremote
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import jwutils.log
|
|||
|
||||
class Object(object): # export
|
||||
|
||||
def __init__():
|
||||
def __init__(self):
|
||||
self.log_level = jwutils.log.level
|
||||
|
||||
def log(self, prio, *args):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
from __future__ import annotations
|
||||
from abc import ABC, abstractmethod
|
||||
from enum import Enum, Flag, auto
|
||||
from typing import *
|
||||
|
||||
def _sigchld_handler(signum, process):
|
||||
if not signum == signal.SIGCHLD:
|
||||
|
|
@ -8,7 +10,7 @@ def _sigchld_handler(signum, process):
|
|||
|
||||
class Process(ABC): # export
|
||||
|
||||
__processes = []
|
||||
__processes: List[Process] = []
|
||||
|
||||
class State(Enum):
|
||||
Running = auto()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from abc import ABC, abstractmethod
|
||||
from typing import Dict, Callable
|
||||
|
||||
_handled_signals = {}
|
||||
_handled_signals: Dict[int, Callable] = {}
|
||||
|
||||
def _signal_handler(signal, frame):
|
||||
if not signal in _handled_signals.keys():
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ if __name__ == '__main__':
|
|||
|
||||
# ------------- testbed calculator
|
||||
|
||||
from string import atof
|
||||
from locale import atof
|
||||
|
||||
class Calculator(ShuntingYard):
|
||||
|
||||
|
|
@ -288,7 +288,7 @@ if __name__ == '__main__':
|
|||
super(Calculator, self).__init__(operators)
|
||||
|
||||
rr = Calculator().eval("( 2 * 3 + 4 * 5 ) / ( 5 - 3 )")
|
||||
self.debug("Result =", rr)
|
||||
print("Result =", rr)
|
||||
|
||||
# ------------- testbed match object
|
||||
|
||||
|
|
@ -335,4 +335,4 @@ if __name__ == '__main__':
|
|||
obj = Object("hans", "wurst")
|
||||
|
||||
r = Matcher(obj).eval("name=hans and (not label~=worst)")
|
||||
self.debug("Result =", r)
|
||||
print("Result =", r)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ import atexit
|
|||
import tempfile
|
||||
import inspect
|
||||
from jwutils import log
|
||||
from typing import Set
|
||||
|
||||
_tmpfiles = set()
|
||||
_tmpfiles: Set[str] = set()
|
||||
|
||||
def _cleanup():
|
||||
for f in _tmpfiles:
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class StringTree: # export
|
|||
self.content = rhs.content
|
||||
for name, c in rhs.children.items():
|
||||
if not name in self.children.keys():
|
||||
slog(DEBUG, "{}: adding new child: ".format(str(self), str(c)))
|
||||
slog(DEBUG, "{}: adding new child: {}".format(str(self), str(c)))
|
||||
self.children[name] = c
|
||||
else:
|
||||
self.children[name].__add_children(c)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue