initial mypy type checking
This commit is contained in:
1
.github/workflows/ci.yml
vendored
1
.github/workflows/ci.yml
vendored
@@ -48,5 +48,6 @@ jobs:
|
||||
- name: Type checking with mypy
|
||||
run: |
|
||||
mypy *.py
|
||||
if: matrix.python-version == "3.x"
|
||||
- name: Test with pytest
|
||||
run: pytest
|
||||
|
||||
@@ -75,17 +75,19 @@ Exception: {e}""")
|
||||
except ImportError:
|
||||
qreader_available = False
|
||||
|
||||
verbose: int
|
||||
quiet: bool
|
||||
|
||||
def sys_main():
|
||||
|
||||
def sys_main() -> None:
|
||||
main(sys.argv[1:])
|
||||
|
||||
|
||||
def main(sys_args):
|
||||
def main(sys_args: list[str]) -> None:
|
||||
# allow to use sys.stdout with with (avoid closing)
|
||||
sys.stdout.close = lambda: None
|
||||
sys.stdout.close = lambda: None # type: ignore
|
||||
|
||||
args = parse_args(sys_args)
|
||||
if verbose: print(f"QReader installed: {qreader_available}")
|
||||
|
||||
otps = extract_otps(args)
|
||||
write_csv(args, otps)
|
||||
@@ -93,7 +95,7 @@ def main(sys_args):
|
||||
write_json(args, otps)
|
||||
|
||||
|
||||
def parse_args(sys_args):
|
||||
def parse_args(sys_args: list[str]) -> argparse.Namespace:
|
||||
global verbose, quiet
|
||||
description_text = "Extracts one time password (OTP) secret keys from QR codes, e.g. from Google Authenticator app."
|
||||
if qreader_available:
|
||||
@@ -126,6 +128,7 @@ b) image file containing a QR code or = for stdin for an image containing a QR c
|
||||
|
||||
verbose = args.verbose if args.verbose else 0
|
||||
quiet = True if args.quiet else False
|
||||
if verbose: print(f"QReader installed: {qreader_available}")
|
||||
|
||||
return args
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ PYTHON="python3.11"
|
||||
PIP="pip3.11"
|
||||
PIPENV="$PYTHON -m pipenv"
|
||||
FLAKE8="$PYTHON -m flake8"
|
||||
MYPY="$PYTHON -m mypy"
|
||||
|
||||
# Upgrade protoc
|
||||
|
||||
@@ -215,11 +216,11 @@ eval "$cmd"
|
||||
|
||||
# Type checking
|
||||
|
||||
cmd="mypy --install-types --non-interactive"
|
||||
cmd="$MYPY --install-types --non-interactive"
|
||||
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
|
||||
eval "$cmd"
|
||||
|
||||
cmd="mypy *.py"
|
||||
cmd="$MYPY *.py"
|
||||
if $interactive ; then askContinueYn "$cmd"; else echo -e "${cyan}$cmd${reset}";fi
|
||||
eval "$cmd"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user