homebrew-core/Formula/black.rb

128 lines
5.5 KiB
Ruby

class Black < Formula
include Language::Python::Virtualenv
desc "Python code formatter"
homepage "https://black.readthedocs.io/en/stable/"
url "https://files.pythonhosted.org/packages/b9/11/bde767284a6a15bf85b53ad696c3658eb3ead74e4697ecda2d07cec106ec/black-21.9b0.tar.gz"
sha256 "7de4cfc7eb6b710de325712d40125689101d21d25283eed7e9998722cf10eb91"
license "MIT"
livecheck do
url :stable
regex(%r{href=.*?/packages.*?/black[._-]v?(\d+(?:\.\d+)*(?:[a-z]\d+)?)\.t}i)
end
bottle do
sha256 cellar: :any_skip_relocation, arm64_big_sur: "143074017e3c4ea2fba3cd65cd613d826b960be6ab1ab3953c0acbc9bdbf2450"
sha256 cellar: :any_skip_relocation, big_sur: "190e78bbb4145eab86f3242c789580e423dba088a5d77e26fa13ccf2e4f89e01"
sha256 cellar: :any_skip_relocation, catalina: "d9403ab95736e25d827aa2094e5f4feff1a78305e3aae6fc5a9603769a2c04b1"
sha256 cellar: :any_skip_relocation, mojave: "845a64efd7b564bffa601acedd5c2615a268346de5369ed5c6d0840e0166ae4f"
sha256 cellar: :any_skip_relocation, x86_64_linux: "048e40e12e76f5b714cd9a048ce243b9f7c96764542f87c13a941e0c9836cc39"
end
depends_on "python@3.9"
resource "aiohttp" do
url "https://files.pythonhosted.org/packages/99/f5/90ede947a3ce2d6de1614799f5fea4e93c19b6520a59dc5d2f64123b032f/aiohttp-3.7.4.post0.tar.gz"
sha256 "493d3299ebe5f5a7c66b9819eacdcfbbaaf1a8e84911ddffcdc48888497afecf"
end
resource "aiohttp_cors" do
url "https://files.pythonhosted.org/packages/44/9e/6cdce7c3f346d8fd487adf68761728ad8cd5fbc296a7b07b92518350d31f/aiohttp-cors-0.7.0.tar.gz"
sha256 "4d39c6d7100fd9764ed1caf8cebf0eb01bf5e3f24e2e073fda6234bc48b19f5d"
end
resource "async-timeout" do
url "https://files.pythonhosted.org/packages/a1/78/aae1545aba6e87e23ecab8d212b58bb70e72164b67eb090b81bb17ad38e3/async-timeout-3.0.1.tar.gz"
sha256 "0c3c816a028d47f659d6ff5c745cb2acf1f966da1fe5c19c77a70282b25f4c5f"
end
resource "attrs" do
url "https://files.pythonhosted.org/packages/ed/d6/3ebca4ca65157c12bd08a63e20ac0bdc21ac7f3694040711f9fd073c0ffb/attrs-21.2.0.tar.gz"
sha256 "ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"
end
resource "chardet" do
url "https://files.pythonhosted.org/packages/ee/2d/9cdc2b527e127b4c9db64b86647d567985940ac3698eeabc7ffaccb4ea61/chardet-4.0.0.tar.gz"
sha256 "0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa"
end
resource "click" do
url "https://files.pythonhosted.org/packages/21/83/308a74ca1104fe1e3197d31693a7a2db67c2d4e668f20f43a2fca491f9f7/click-8.0.1.tar.gz"
sha256 "8c04c11192119b1ef78ea049e0a6f0463e4c48ef00a30160c704337586f3ad7a"
end
resource "idna" do
url "https://files.pythonhosted.org/packages/cb/38/4c4d00ddfa48abe616d7e572e02a04273603db446975ab46bbcd36552005/idna-3.2.tar.gz"
sha256 "467fbad99067910785144ce333826c71fb0e63a425657295239737f7ecd125f3"
end
resource "multidict" do
url "https://files.pythonhosted.org/packages/1c/74/e8b46156f37ca56d10d895d4e8595aa2b344cff3c1fb3629ec97a8656ccb/multidict-5.1.0.tar.gz"
sha256 "25b4e5f22d3a37ddf3effc0710ba692cfc792c2b9edfb9c05aefe823256e84d5"
end
resource "mypy-extensions" do
url "https://files.pythonhosted.org/packages/63/60/0582ce2eaced55f65a4406fc97beba256de4b7a95a0034c6576458c6519f/mypy_extensions-0.4.3.tar.gz"
sha256 "2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
end
resource "pathspec" do
url "https://files.pythonhosted.org/packages/f6/33/436c5cb94e9f8902e59d1d544eb298b83c84b9ec37b5b769c5a0ad6edb19/pathspec-0.9.0.tar.gz"
sha256 "e564499435a2673d586f6b2130bb5b95f04a3ba06f81b8f895b651a3c76aabb1"
end
resource "platformdirs" do
url "https://files.pythonhosted.org/packages/e2/d4/c6ffe89de09851892b1418dc22f6ab019b7b6f362532ab813c262e1722bb/platformdirs-2.3.0.tar.gz"
sha256 "15b056538719b1c94bdaccb29e5f81879c7f7f0f4a153f46086d155dffcd4f0f"
end
resource "regex" do
url "https://files.pythonhosted.org/packages/15/bd/88d793c2e39b1e91c070bf4d1317db599b1c22efbf6bd194bb568064af21/regex-2021.8.28.tar.gz"
sha256 "f585cbbeecb35f35609edccb95efd95a3e35824cd7752b586503f7e6087303f1"
end
resource "tomli" do
url "https://files.pythonhosted.org/packages/75/50/973397c5ba854445bcc396b593b5db1958da6ab8d665b27397daa1497018/tomli-1.2.1.tar.gz"
sha256 "a5b75cb6f3968abb47af1b40c1819dc519ea82bcc065776a866e8d74c5ca9442"
end
resource "typing-extensions" do
url "https://files.pythonhosted.org/packages/ed/12/c5079a15cf5c01d7f4252b473b00f7e68ee711be605b9f001528f0298b98/typing_extensions-3.10.0.2.tar.gz"
sha256 "49f75d16ff11f1cd258e1b988ccff82a3ca5570217d7ad8c5f48205dd99a677e"
end
resource "yarl" do
url "https://files.pythonhosted.org/packages/97/e7/af7219a0fe240e8ef6bb555341a63c43045c21ab0392b4435e754b716fa1/yarl-1.6.3.tar.gz"
sha256 "8a9066529240171b68893d60dca86a763eae2139dd42f42106b03cf4b426bf10"
end
def install
virtualenv_install_with_resources
end
plist_options startup: true
service do
run opt_bin/"blackd"
keep_alive true
working_dir HOMEBREW_PREFIX
log_path var/"log/blackd.log"
error_log_path var/"log/blackd.log"
end
test do
ENV["LC_ALL"] = "en_US.UTF-8"
(testpath/"black_test.py").write <<~EOS
print(
'It works!')
EOS
system bin/"black", "black_test.py"
assert_equal "print(\"It works!\")\n", (testpath/"black_test.py").read
port = free_port
fork { exec "#{bin}/blackd --bind-host 127.0.0.1 --bind-port #{port}" }
sleep 10
assert_match "print(\"valid\")", shell_output("curl -s -XPOST localhost:#{port} -d \"print('valid')\"").strip
end
end