summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Reiter <reiter.christoph@gmail.com>2020-11-08 14:58:08 +0000
committerChristoph Reiter <reiter.christoph@gmail.com>2020-11-08 14:58:08 +0000
commitaa0bbaa548bd31933d3cbf5257d9487574e072d2 (patch)
treef57fc5a1eaac3f1a537ee5bd1dd9fad745edab2c
parent11bb4b3d1fcf7395cb6bb034186427cc66e2999a (diff)
parent1b3237ba383ba644628defcfde443e9a4e5af69c (diff)
downloadgobject-introspection-aa0bbaa548bd31933d3cbf5257d9487574e072d2.tar.gz
Merge branch 'mypy-basics' into 'master'
Add basic mypy support; Require Python 3.5 See merge request GNOME/gobject-introspection!251
-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--meson.build2
-rw-r--r--mypy.ini3
8 files changed, 16 insertions, 7 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 a49aca6b..45807f17 100644
--- a/giscanner/utils.py
+++ b/giscanner/utils.py
@@ -332,5 +332,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/meson.build b/meson.build
index 3bbcf8de..546ab885 100644
--- a/meson.build
+++ b/meson.build
@@ -18,7 +18,7 @@ pymod = import('python')
python = pymod.find_installation(get_option('python'))
python_version = python.language_version()
-python_version_req = '>=3.4'
+python_version_req = '>=3.5'
if not python_version.version_compare(python_version_req)
error('Requires Python @0@, @1@ found.'.format(python_version_req, python_version))
endif
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