From 802c5b59cb3e7e7a241c764ef92f117f4510f4c6 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 17 Mar 2020 01:11:49 -0300 Subject: [PATCH] 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. --- Makefile | 2 +- pylib/Makefile | 21 +++++++++++++++++++-- pylib/mypy.ini | 1 - qt/Makefile | 24 ++++++++++++++++++++++-- qt/mypy.ini | 1 - rspy/Makefile | 2 +- 6 files changed, 43 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index fdfa2c182..5ade34310 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ ifndef OS OS := unknown endif -ifeq ($(OS),Windows_NT) +ifeq (${OS},Windows_NT) ifndef ACTIVATE_SCRIPT ACTIVATE_SCRIPT := pyenv/Scripts/activate endif diff --git a/pylib/Makefile b/pylib/Makefile index 96ed9cfd0..a81d32416 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -1,5 +1,21 @@ SHELL := /bin/bash 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 .DELETE_ON_ERROR: @@ -59,7 +75,7 @@ clean: CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py) .build/mypy: $(CHECKDEPS) - python -m mypy anki + python -m mypy ${MYPY_IGNORED_IMPORTS} anki @touch $@ .build/test: $(CHECKDEPS) @@ -67,7 +83,8 @@ CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py) @touch $@ .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 $@ .build/imports: $(CHECKDEPS) diff --git a/pylib/mypy.ini b/pylib/mypy.ini index 4215061bb..6ad6b351b 100644 --- a/pylib/mypy.ini +++ b/pylib/mypy.ini @@ -7,7 +7,6 @@ check_untyped_defs = true disallow_untyped_decorators = True warn_redundant_casts = True warn_unused_configs = True -warn_unused_ignores = True [mypy-win32file] ignore_missing_imports = True diff --git a/qt/Makefile b/qt/Makefile index e6aa5e899..ce9f8961f 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -1,5 +1,24 @@ SHELL := /bin/bash 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 .DELETE_ON_ERROR: @@ -80,7 +99,7 @@ PYLIB := ../pylib CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py) .build/mypy: $(CHECKDEPS) .build/qt-stubs - python -m mypy aqt + python -m mypy ${MYPY_IGNORED_IMPORTS} aqt @touch $@ .build/test: $(CHECKDEPS) @@ -88,7 +107,8 @@ CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py) @touch $@ .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 $@ .build/imports: $(CHECKDEPS) diff --git a/qt/mypy.ini b/qt/mypy.ini index 5d5a5ca40..a69375016 100644 --- a/qt/mypy.ini +++ b/qt/mypy.ini @@ -6,7 +6,6 @@ show_error_codes = true disallow_untyped_decorators = True warn_redundant_casts = True warn_unused_configs = True -warn_unused_ignores = True [mypy-win32file] ignore_missing_imports = True diff --git a/rspy/Makefile b/rspy/Makefile index 798a67515..49c5237b6 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -5,7 +5,7 @@ ifndef OS OS := unknown endif -ifeq ($(OS),Windows_NT) +ifeq (${OS},Windows_NT) ifndef PYTHON_BIN PYTHON_BIN := python endif