/
vint.rb
95 lines (80 loc) 路 3.58 KB
/
vint.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class Vint < Formula
include Language::Python::Virtualenv
desc "Vim script Language Lint"
homepage "https://github.com/Vimjas/vint"
url "https://files.pythonhosted.org/packages/9c/c7/d5fbe5f778edee83cba3aea8cc3308db327e4c161e0656e861b9cc2cb859/vim-vint-0.3.21.tar.gz"
sha256 "5dc59b2e5c2a746c88f5f51f3fafea3d639c6b0fdbb116bb74af27bf1c820d97"
license "MIT"
revision 2
head "https://github.com/Vimjas/vint.git", branch: "master"
bottle do
rebuild 5
sha256 cellar: :any, arm64_sonoma: "e2b4843f23ddcae97ec2eec6912274d2863faffb3e6f33f262f3f4814fec94fb"
sha256 cellar: :any, arm64_ventura: "f0cd321fba48f328e3c13dab7aecf72ad8c7461b52cf007220d3b24fbf986edb"
sha256 cellar: :any, arm64_monterey: "81fbb3743b862c733415a7487a2c94d94efd047adbcac284c71e1f151b04cd95"
sha256 cellar: :any, sonoma: "96a23e4d02eabbfc64e0085e078a1249095c675ab9129e6f8f913c874649e8d1"
sha256 cellar: :any, ventura: "0dd3fe045ce35748872c0d023d58cff039f7637485a68a4500d419b90b298637"
sha256 cellar: :any, monterey: "6f214063ba0784a2adb96138a19003def055f2a9b99cad00c6f5947a847238f1"
sha256 cellar: :any_skip_relocation, x86_64_linux: "933837ebcda670e4b4a7ca57e3352212f75d5152565e482cd4e37577e8eb4013"
end
depends_on "libyaml"
depends_on "python@3.12"
resource "ansicolor" do
url "https://files.pythonhosted.org/packages/79/74/630817c7eb1289a1412fcc4faeca74a69760d9c9b0db94fc09c91978a6ac/ansicolor-0.3.2.tar.gz"
sha256 "3b840a6b1184b5f1568635b1adab28147947522707d41ceba02d5ed0a0877279"
end
resource "chardet" do
url "https://files.pythonhosted.org/packages/f3/0d/f7b6ab21ec75897ed80c17d79b15951a719226b9fababf1e40ea74d69079/chardet-5.2.0.tar.gz"
sha256 "1b3b6ff479a8c414bc3fa2c0852995695c4a026dcd6d0633b2dd092ca39c1cf7"
end
resource "pyyaml" do
url "https://files.pythonhosted.org/packages/cd/e5/af35f7ea75cf72f2cd079c95ee16797de7cd71f29ea7c68ae5ce7be1eda0/PyYAML-6.0.1.tar.gz"
sha256 "bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"
end
# Drop setuptools dep. Next release will switch to setuptools_scm,
# this patch uses importlib for a smaller self-contained diff
# https://github.com/Vimjas/vint/commit/997677ae688fbaf47da426500cc56aae7305d243
patch :DATA
def install
virtualenv_install_with_resources
end
test do
system bin/"vint", "--help"
(testpath/"bad.vim").write <<~EOS
not vimscript
EOS
assert_match "E492", shell_output("#{bin}/vint bad.vim", 1)
(testpath/"good.vim").write <<~EOS
" minimal vimrc
syntax on
set backspace=indent,eol,start
filetype plugin indent on
EOS
assert_equal "", shell_output("#{bin}/vint good.vim")
end
end
__END__
diff --git a/vint/linting/cli.py b/vint/linting/cli.py
index 55db52e..c347f23 100644
--- a/vint/linting/cli.py
+++ b/vint/linting/cli.py
@@ -1,7 +1,6 @@
import sys
from argparse import ArgumentParser
from pathlib import PosixPath
-import pkg_resources
import logging
from vint.linting.linter import Linter
@@ -150,11 +149,11 @@ class CLI(object):
def _get_version(self):
- # In unit tests, pkg_resources cannot find vim-vint.
- # So, I decided to return dummy version
+ from importlib import metadata
+
try:
- version = pkg_resources.require('vim-vint')[0].version
- except pkg_resources.DistributionNotFound:
+ version = metadata.version('vim-vint')
+ except metadata.PackageNotFoundError:
version = 'test_mode'
return version