mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1460402 - Update the codespell support to use pip instead of the package r=ahal
MozReview-Commit-ID: J4wS7s9sWFe --HG-- extra : rebase_source : 4666a3e5bab6ee5ca95fcc31da4ef625e46e2d59
This commit is contained in:
parent
814ff726f3
commit
b86503f980
@ -16,22 +16,29 @@ except ImportError:
|
||||
JSONDecodeError = ValueError
|
||||
|
||||
from mozlint import result
|
||||
from mozlint.util import pip
|
||||
from mozprocess import ProcessHandlerMixin
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
CODESPELL_REQUIREMENTS_PATH = os.path.join(here, 'codespell_requirements.txt')
|
||||
|
||||
CODESPELL_NOT_FOUND = """
|
||||
Unable to locate codespell, please ensure it is installed and in
|
||||
your PATH or set the CODESPELL environment variable.
|
||||
Could not find codespell! Install codespell and try again.
|
||||
|
||||
https://github.com/lucasdemarchi/codespell or your system's package manager.
|
||||
""".strip()
|
||||
$ pip install -U --require-hashes -r {}
|
||||
""".strip().format(CODESPELL_REQUIREMENTS_PATH)
|
||||
|
||||
|
||||
CODESPELL_INSTALL_ERROR = """
|
||||
Unable to install correct version of codespell
|
||||
Try to install it manually with:
|
||||
$ pip install -U --require-hashes -r {}
|
||||
""".strip().format(CODESPELL_REQUIREMENTS_PATH)
|
||||
|
||||
results = []
|
||||
|
||||
CODESPELL_FORMAT_REGEX = re.compile(r'(.*):(.*): (.*) ==> (.*)$')
|
||||
|
||||
here = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
class CodespellProcess(ProcessHandlerMixin):
|
||||
def __init__(self, config, *args, **kwargs):
|
||||
@ -91,6 +98,10 @@ def get_codespell_binary():
|
||||
|
||||
def lint(paths, config, fix=None, **lintargs):
|
||||
|
||||
if not pip.reinstall_program(CODESPELL_REQUIREMENTS_PATH):
|
||||
print(CODESPELL_INSTALL_ERROR)
|
||||
return 1
|
||||
|
||||
binary = get_codespell_binary()
|
||||
|
||||
if not binary:
|
||||
|
2
tools/lint/spell/codespell_requirements.txt
Normal file
2
tools/lint/spell/codespell_requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
codespell==1.12.0 \
|
||||
--hash=sha256:f547ef6ea3af4569b0a4d3ef106ef6403f6ee574afdaa8e332650aea87301daf
|
Loading…
Reference in New Issue
Block a user