diff --git a/buildpy/lint.py b/buildpy/lint.py index 82da59a..1a800f5 100644 --- a/buildpy/lint.py +++ b/buildpy/lint.py @@ -66,11 +66,13 @@ def create_output(self) -> str: @click.option('-d', '--directory', 'directory', required=False, type=str) @click.option('-o', '--output-file', 'outputFilename', required=False, type=str) @click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty') -def run(directory: str, outputFilename: str, outputFormat: str) -> None: +@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str) +def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None: currentDirectory = os.path.dirname(os.path.realpath(__file__)) targetDirectory = os.path.abspath(directory or os.getcwd()) reporter = GitHubAnnotationsReporter() if outputFormat == 'annotations' else PrettyReporter() - run_pylint([f'--rcfile={currentDirectory}/pylintrc', targetDirectory], reporter=reporter, exit=False) + pylintConfigFilePath = configFilePath or f'{currentDirectory}/pylintrc' + run_pylint([f'--rcfile={pylintConfigFilePath}', targetDirectory], reporter=reporter, exit=False) output = reporter.create_output() # type: ignore if outputFilename: with open(outputFilename, 'w') as outputFile: diff --git a/buildpy/type_check.py b/buildpy/type_check.py index 0c78437..249d228 100644 --- a/buildpy/type_check.py +++ b/buildpy/type_check.py @@ -89,13 +89,15 @@ def create_output(self, messages: List[str]) -> str: @click.option('-d', '--directory', 'directory', required=False, type=str) @click.option('-o', '--output-file', 'outputFilename', required=False, type=str) @click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty') -def run(directory: str, outputFilename: str, outputFormat: str) -> None: +@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str) +def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None: currentDirectory = os.path.dirname(os.path.realpath(__file__)) targetDirectory = os.path.abspath(directory or os.getcwd()) reporter = GitHubAnnotationsReporter() if outputFormat == 'annotations' else PrettyReporter() messages = [] + mypyConfigFilePath = configFilePath or f'{currentDirectory}/mypy.ini' try: - subprocess.check_output(f'mypy {targetDirectory} --config-file {currentDirectory}/mypy.ini --no-color-output --no-error-summary --show-column-numbers', stderr=subprocess.STDOUT, shell=True) + subprocess.check_output(f'mypy {targetDirectory} --config-file {mypyConfigFilePath} --no-color-output --no-error-summary --show-column-numbers', stderr=subprocess.STDOUT, shell=True) except subprocess.CalledProcessError as exception: messages = exception.output.decode().split('\n') output = reporter.create_output(messages=messages) # type: ignore