Fixed mypy and pylint not building on Windows

1. error: unused 'type: ignore' comment
2. Module 'pywintypes' has no 'error' member
3. Module 'win32pipe' has no 'SetNamedPipeHandleState' member,
   but source is unavailable. Consider adding this module to
   extension-pkg-whitelist if you want to perform analysis based on
   run-time introspection of living objects.
This commit is contained in:
evandrocoan 2020-03-17 01:11:49 -03:00
parent 034ac10cf4
commit 802c5b59cb
6 changed files with 43 additions and 8 deletions

View file

@ -4,7 +4,7 @@ ifndef OS
OS := unknown OS := unknown
endif endif
ifeq ($(OS),Windows_NT) ifeq (${OS},Windows_NT)
ifndef ACTIVATE_SCRIPT ifndef ACTIVATE_SCRIPT
ACTIVATE_SCRIPT := pyenv/Scripts/activate ACTIVATE_SCRIPT := pyenv/Scripts/activate
endif endif

View file

@ -1,5 +1,21 @@
SHELL := /bin/bash SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
MYPY_IGNORED_IMPORTS :=
ifndef OS
OS := unknown
endif
ifndef UNAME
UNAME := unknown
endif
# https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment
ifneq (${OS},Windows_NT)
ifneq (${UNAME},Darwin)
MYPY_IGNORED_IMPORTS := --warn-unused-ignores
endif
endif
.SHELLFLAGS := -eu -o pipefail -c .SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
@ -59,7 +75,7 @@ clean:
CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py) CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py)
.build/mypy: $(CHECKDEPS) .build/mypy: $(CHECKDEPS)
python -m mypy anki python -m mypy ${MYPY_IGNORED_IMPORTS} anki
@touch $@ @touch $@
.build/test: $(CHECKDEPS) .build/test: $(CHECKDEPS)
@ -67,7 +83,8 @@ CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py)
@touch $@ @touch $@
.build/lint: $(CHECKDEPS) .build/lint: $(CHECKDEPS)
python -m pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=ankirspy anki tests setup.py python -m pylint -j 0 --rcfile=.pylintrc -f colorized \
--extension-pkg-whitelist=ankirspy anki tests setup.py
@touch $@ @touch $@
.build/imports: $(CHECKDEPS) .build/imports: $(CHECKDEPS)

View file

@ -7,7 +7,6 @@ check_untyped_defs = true
disallow_untyped_decorators = True disallow_untyped_decorators = True
warn_redundant_casts = True warn_redundant_casts = True
warn_unused_configs = True warn_unused_configs = True
warn_unused_ignores = True
[mypy-win32file] [mypy-win32file]
ignore_missing_imports = True ignore_missing_imports = True

View file

@ -1,5 +1,24 @@
SHELL := /bin/bash SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
MYPY_IGNORED_IMPORTS :=
PYLINT_IGNORED_MODULES :=
ifndef OS
OS := unknown
endif
ifndef UNAME
UNAME := unknown
endif
# https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment
ifneq (${OS},Windows_NT)
ifneq (${UNAME},Darwin)
MYPY_IGNORED_IMPORTS := --warn-unused-ignores
endif
else
PYLINT_IGNORED_MODULES := --ignored-modules=win32file,pywintypes,socket,win32pipe
endif
.SHELLFLAGS := -eu -o pipefail -c .SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
@ -80,7 +99,7 @@ PYLIB := ../pylib
CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py) CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py)
.build/mypy: $(CHECKDEPS) .build/qt-stubs .build/mypy: $(CHECKDEPS) .build/qt-stubs
python -m mypy aqt python -m mypy ${MYPY_IGNORED_IMPORTS} aqt
@touch $@ @touch $@
.build/test: $(CHECKDEPS) .build/test: $(CHECKDEPS)
@ -88,7 +107,8 @@ CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py)
@touch $@ @touch $@
.build/lint: $(CHECKDEPS) .build/lint: $(CHECKDEPS)
python -m pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,ankirspy aqt tests setup.py python -m pylint -j 0 --rcfile=.pylintrc -f colorized ${PYLINT_IGNORED_MODULES} \
--extension-pkg-whitelist=PyQt5,ankirspy aqt tests setup.py
@touch $@ @touch $@
.build/imports: $(CHECKDEPS) .build/imports: $(CHECKDEPS)

View file

@ -6,7 +6,6 @@ show_error_codes = true
disallow_untyped_decorators = True disallow_untyped_decorators = True
warn_redundant_casts = True warn_redundant_casts = True
warn_unused_configs = True warn_unused_configs = True
warn_unused_ignores = True
[mypy-win32file] [mypy-win32file]
ignore_missing_imports = True ignore_missing_imports = True

View file

@ -5,7 +5,7 @@ ifndef OS
OS := unknown OS := unknown
endif endif
ifeq ($(OS),Windows_NT) ifeq (${OS},Windows_NT)
ifndef PYTHON_BIN ifndef PYTHON_BIN
PYTHON_BIN := python PYTHON_BIN := python
endif endif