class Mypy < Formula desc "Experimental optional static type checker for Python" homepage "http://www.mypy-lang.org/" url "https://github.com/python/mypy.git", :tag => "v0.521", :revision => "858f7512cf3b4e39c0f4e8de5a13eee0e1e138fb" head "https://github.com/python/mypy.git" bottle do cellar :any_skip_relocation sha256 "7952339760f6b000890303e5b406550ff0ceeb939dcaf2729aa80cad4263880a" => :sierra sha256 "453f964e8baec4161eeaec56d23cc926b561deedd07c8a32d5fba88e018e770b" => :el_capitan sha256 "0dd45349792469d6544f4ac2ef41c6d1a6d2fc984dbb8ef0ed2782e8a6caa269" => :yosemite end option "without-sphinx-doc", "Don't build documentation" deprecated_option "without-docs" => "without-sphinx-doc" depends_on :python3 depends_on "sphinx-doc" => [:build, :recommended] resource "sphinx_rtd_theme" do url "https://files.pythonhosted.org/packages/8b/e5/b1933472424b30affb0a8cea8f0ef052a31ada96e5d1823911d7f4bfdf8e/sphinx_rtd_theme-0.2.4.tar.gz" sha256 "2df74b8ff6fae6965c527e97cca6c6c944886aae474b490e17f92adfbe843417" end resource "typed-ast" do url "https://files.pythonhosted.org/packages/6c/8c/308968906916c5523c3a0e5ecb8ba8d79b8baf67f05faf1dffcb2a78ae7e/typed-ast-1.0.4.tar.gz" sha256 "73f09aac0119f6664a3f471a1ec1c9b719f572bc9212913cea96a78b22c2e96e" end def install xy = Language::Python.major_minor_version "python3" if build.with? "sphinx-doc" # https://github.com/python/mypy/issues/2593 version_static = buildpath/"mypy/version_static.py" version_static.write "__version__ = '#{version}'\n" inreplace "docs/source/conf.py", "mypy.version", "mypy.version_static" (buildpath/"docs/sphinx_rtd_theme").install resource("sphinx_rtd_theme") # Inject sphinx_rtd_theme's path into sys.path inreplace "docs/source/conf.py", "sys.path.insert(0, os.path.abspath('../..'))", "sys.path[:0] = [os.path.abspath('../..'), os.path.abspath('../sphinx_rtd_theme')]" system "make", "-C", "docs", "html" doc.install Dir["docs/build/html/*"] rm version_static end ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{xy}/site-packages" resources.each do |r| r.stage do system "python3", *Language::Python.setup_install_args(libexec/"vendor") end end ENV.prepend_create_path "PYTHONPATH", libexec/"lib/python#{xy}/site-packages" system "python3", *Language::Python.setup_install_args(libexec) bin.install Dir[libexec/"bin/*"] bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) end test do (testpath/"broken.py").write <<-EOS.undent def p() -> None: print('hello') a = p() EOS output = pipe_output("#{bin}/mypy broken.py 2>&1") assert_match '"p" does not return a value', output end end