D6717: mypy: add a mypy.ini config file

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Sun Aug 4 19:53:04 UTC 2019


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Static analysis is good. Let's encourage its use by adding
  a mypy.ini config file to the repo that has reasonable defaults.
  
  With this file in place, `mypy` appears to "just work" out of
  the box. It yields a ton of errors and warnings though. But
  it's a start!

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6717

AFFECTED FILES
  mypy.ini

CHANGE DETAILS

diff --git a/mypy.ini b/mypy.ini
new file mode 100644
--- /dev/null
+++ b/mypy.ini
@@ -0,0 +1,29 @@
+# To run mypy against Mercurial, do something like the following:
+#
+#   $ python3.7 -m pip install mypy
+#   $ python3.7 mypy
+#
+# Note: Mercurial's source tree has source files that may not parse
+# on the version of Python being targeted. Currently released versions
+# of mypy treat parse errors as fatal. To work around this, install
+# a mypy with the change from https://github.com/python/mypy/pull/7286
+# and uncomment the `ignore_parse_errors` line below.
+
+[mypy]
+files = hgext/**/*.py, hgdemandimport/**/*.py, mercurial/**/*.py
+cache_dir = build/mypy-cache
+
+# By default mypy targets the Python version it runs as. Mypy requires
+# Python 3.5 to run.
+python_version = 2.7
+
+# Various functionality is optional. Suppress missing imports globally
+# to cut down on noise.
+ignore_missing_imports = True
+
+# TODO enable once feature lands upstream
+# ignore_parse_errors = True
+
+# We don't control third party code. Don't error on it.
+[mypy-mercurial.thirdparty.*]
+ignore_errors = True



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list