/
pycodestyle.rb
46 lines (39 loc) 路 1.37 KB
/
pycodestyle.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
class Pycodestyle < Formula
include Language::Python::Shebang
desc "Simple Python style checker in one Python file"
homepage "https://pycodestyle.pycqa.org/"
url "https://github.com/PyCQA/pycodestyle/archive/refs/tags/2.11.1.tar.gz"
sha256 "a01fdd890c6472eebc32e8baf21e29173c35776e765c64cc83ccd09b99dc5399"
license "MIT"
head "https://github.com/PyCQA/pycodestyle.git", branch: "master"
bottle do
rebuild 1
sha256 cellar: :any_skip_relocation, all: "09b8e38e31a5647a76ac32d163628e69211c67ad0a09d7b34313d9791a6278d4"
end
depends_on "python@3.12"
def install
rewrite_shebang detected_python_shebang, "pycodestyle.py"
bin.install "pycodestyle.py" => "pycodestyle"
end
test do
# test invocation on a file with no issues
(testpath/"ok.py").write <<~EOS
print(1)
EOS
assert_equal "",
shell_output("#{bin}/pycodestyle ok.py")
# test invocation on a file with a whitespace style issue
(testpath/"ws.py").write <<~EOS
print( 1)
EOS
assert_equal "ws.py:1:7: E201 whitespace after '('\n",
shell_output("#{bin}/pycodestyle ws.py", 1)
# test invocation on a file with an import not at top of file
(testpath/"imp.py").write <<~EOS
pass
import sys
EOS
assert_equal "imp.py:2:1: E402 module level import not at top of file\n",
shell_output("#{bin}/pycodestyle imp.py", 1)
end
end