Repository: python/mypy

Issue:
`TypeError: int object expected` on compiled wheel
* Are you reporting a bug, or opening a feature request? **Bug**

`mypyc` compiled version of latest mypy HEAD (`mypy-0.710+dev.e06378c1bd0e6b30070bf9d3188e4ae62200ecd4`, installed from `mypy-0.710+dev.e06378c1bd0e6b30070bf9d3188e4ae62200ecd4-cp37-cp37m-macosx_10_6_x86_64.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl` in the mypyc-wheels repo).

Running the mypy command with `--help` or `--version` flags crashes with `TypeError: int object expected`. Running without any flags, or running as normal in type checking mode, works fine.

* What are the versions of mypy and Python you are using?
  Do you see the same issue after installing mypy from Git master?

`mypy --version`: Well... (See above)
`python --version`: Python 3.7.3
Installing from git master and running as normal (non-compiled) code works normally, it seems to be an issue in the `mypyc` compiled version. Not sure if it's `mypy` or `mypyc` who's the culprit.

* If mypy crashed with a traceback, please paste
  the full traceback below.
<details>
<summary>Traceback</summary>

```
$ mypy --version
Traceback (most recent call last):
  File "/usr/local/bin/mypy", line 10, in <module>
    sys.exit(console_entry())
  File "/usr/local/lib/python3.7/site-packages/mypy/__main__.py", line 8, in console_entry
    main(None, sys.stdout, sys.stderr)
  File "mypy/main.py", line 67, in main
  File "mypy/main.py", line 671, in process_options
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1749, in parse_args
    args, argv = self.parse_known_args(args, namespace)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1781, in parse_known_args
    namespace, args = self._parse_known_args(args, namespace)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1987, in _parse_known_args
    start_index = consume_optional(start_index)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1927, in consume_optional
    take_action(action, args, option_string)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1855, in take_action
    action(self, namespace, argument_values, option_string)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 1063, in __call__
    parser._print_message(formatter.format_help(), _sys.stdout)
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 284, in format_help
    help = self._root_section.format_help()
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 215, in format_help
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 215, in <listcomp>
    item_help = join([func(*args) for func, args in self.items])
  File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/argparse.py", line 493, in _format_text
    return self._fill_text(text, text_width, indent) + '\n\n'
TypeError: int object expected
```

</details>


Discussion:
I can't reproduce this on MacOS 10.14.5 and Python 3.7.3.
Here's a minimal Dockerfile that reproduces it on Python 3.6 (Linux): https://gist.github.com/ROpdebee/1daa99513efec3778505f06552a5abb3
Yeah that sure is busted.

Resolving patch:
diff --git a/mypy/main.py b/mypy/main.py
--- a/mypy/main.py
+++ b/mypy/main.py
@@ -6,7 +6,7 @@
 import sys
 import time
 
-from typing import Dict, List, Optional, Tuple, TextIO
+from typing import Any, Dict, List, Optional, Tuple, TextIO
 
 from mypy import build
 from mypy import defaults
@@ -124,7 +124,9 @@ class AugmentedHelpFormatter(argparse.RawDescriptionHelpFormatter):
     def __init__(self, prog: str) -> None:
         super().__init__(prog=prog, max_help_position=28)
 
-    def _fill_text(self, text: str, width: int, indent: int) -> str:
+    # FIXME: typeshed incorrectly has the type of indent as int when
+    # it should be str. Make it Any to avoid rusing mypyc.
+    def _fill_text(self, text: str, width: int, indent: Any) -> str:
         if '\n' in text:
             # Assume we want to manually format the text
             return super()._fill_text(text, width, indent)


Test patch: