summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-11-07 11:00:30 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2020-11-07 11:10:01 +0100
commit1b3237ba383ba644628defcfde443e9a4e5af69c (patch)
treefff15e73a0c5973ee105b11301f021edd8320a51
parent3e5eece5e1e5d77d2c5ea355bc8637549388b9d5 (diff)
downloadgobject-introspection-1b3237ba383ba644628defcfde443e9a4e5af69c.tar.gz
Add basic mypy support
Silence some errors, run mypy in CI Adding annotations to functions/classes will make mypy check them.
-rw-r--r--.gitignore3
-rw-r--r--.gitlab-ci.yml3
-rw-r--r--.gitlab-ci/test-msys2-meson.sh3
-rw-r--r--giscanner/__init__.py2
-rw-r--r--giscanner/annotationparser.py3
-rw-r--r--giscanner/utils.py4
-rw-r--r--mypy.ini3
7 files changed, 15 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 2f1be723..1e9e54eb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,3 +155,6 @@ htmlcov*
#emacs
.dir-locals.el
+
+
+.mypy_cache \ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index e9e79b97..2d79aa1d 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -56,8 +56,9 @@ fedora-x86_64-meson:
- cd ..
- mkdir -p public
- mv _build/docs/reference/html/ public/girepository/
- - python3 -m pip install --user flake8
+ - python3 -m pip install --user flake8 mypy
- python3 -m flake8 --count
+ - python3 -m mypy .
except:
- tags
artifacts:
diff --git a/.gitlab-ci/test-msys2-meson.sh b/.gitlab-ci/test-msys2-meson.sh
index 9f145e5b..81a82437 100644
--- a/.gitlab-ci/test-msys2-meson.sh
+++ b/.gitlab-ci/test-msys2-meson.sh
@@ -31,7 +31,7 @@ pacman --noconfirm -S --needed \
export CCACHE_BASEDIR="${CI_PROJECT_DIR}"
export CCACHE_DIR="${CCACHE_BASEDIR}/_ccache"
-pip3 install --upgrade --user meson==0.50.1 flake8
+pip3 install --upgrade --user meson==0.50.1 flake8 mypy
export PATH="$HOME/.local/bin:$PATH"
export CFLAGS="-Werror"
@@ -43,3 +43,4 @@ meson test --print-errorlogs --suite=gobject-introspection --no-suite=glib
cd ..
python3 -m flake8 --count
+python3 -m mypy . \ No newline at end of file
diff --git a/giscanner/__init__.py b/giscanner/__init__.py
index 79c537e8..7c2f365a 100644
--- a/giscanner/__init__.py
+++ b/giscanner/__init__.py
@@ -20,7 +20,7 @@
import os
builddir = os.environ.get('UNINSTALLED_INTROSPECTION_BUILDDIR')
if builddir is not None:
- __path__.append(os.path.join(builddir, 'giscanner'))
+ __path__.append(os.path.join(builddir, 'giscanner')) # type: ignore # mypy issue #1422
try:
from ._version import __version__
except ImportError:
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index f8257206..267542f9 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -110,6 +110,7 @@ import os
import re
import operator
+from typing import Tuple
from operator import ne, gt, lt
from collections import namedtuple, Counter, OrderedDict
@@ -575,7 +576,7 @@ class GtkDocAnnotatable(object):
#: A :class:`tuple` of annotation name constants that are valid for this object. Annotation
#: names not in this :class:`tuple` will be reported as *unknown* by :func:`validate`. The
#: :attr:`valid_annotations` class attribute should be overridden by subclasses.
- valid_annotations = ()
+ valid_annotations = () # type: Tuple[str,...]
def __init__(self, position=None):
#: A :class:`giscanner.message.Position` instance specifying the location of the
diff --git a/giscanner/utils.py b/giscanner/utils.py
index d9938fc7..9007db13 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -346,5 +346,5 @@ def get_msvcr_overwrite():
import distutils.cygwinccompiler
-orig_get_msvcr = distutils.cygwinccompiler.get_msvcr
-distutils.cygwinccompiler.get_msvcr = get_msvcr_overwrite
+orig_get_msvcr = distutils.cygwinccompiler.get_msvcr # type: ignore
+distutils.cygwinccompiler.get_msvcr = get_msvcr_overwrite # type: ignore
diff --git a/mypy.ini b/mypy.ini
new file mode 100644
index 00000000..e69a623d
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,3 @@
+[mypy]
+ignore_missing_imports = True
+python_version = 3.5 \ No newline at end of file