Patchwork D6717: mypy: add a mypy.ini config file

login
register
mail settings
Submitter phabricator
Date Aug. 4, 2019, 7:53 p.m.
Message ID <differential-rev-PHID-DREV-bf4dwfzxknftmoe5rl43-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/41146/
State New
Headers show

Comments

phabricator - Aug. 4, 2019, 7:53 p.m.
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




To: indygreg, #hg-reviewers
Cc: mercurial-devel
phabricator - Aug. 7, 2019, 10:20 p.m.
pulkit added a comment.


  I am +1 on this. If I don't hear any objection on it until next week, I will queue it. Thanks for doing this work!

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6717/new/

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

To: indygreg, #hg-reviewers
Cc: pulkit, mercurial-devel
phabricator - Aug. 14, 2019, 7:23 p.m.
durin42 added a comment.


  Did you run tests on this patch? IIRC there's a test that'll fail ;)

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6717/new/

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

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

Patch

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