Skip to content

Commit 5e17c28

Browse files
PattenRkrishan711
andauthored
Feature: Custom configs for mypy and pylint (#5)
* Feature - Custom configs for mypy and pylint * Update setup.py Co-authored-by: Krishan Patel <[email protected]>
1 parent 9016acd commit 5e17c28

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

buildpy/lint.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,13 @@ def create_output(self) -> str:
6666
@click.option('-d', '--directory', 'directory', required=False, type=str)
6767
@click.option('-o', '--output-file', 'outputFilename', required=False, type=str)
6868
@click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty')
69-
def run(directory: str, outputFilename: str, outputFormat: str) -> None:
69+
@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str)
70+
def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None:
7071
currentDirectory = os.path.dirname(os.path.realpath(__file__))
7172
targetDirectory = os.path.abspath(directory or os.getcwd())
7273
reporter = GitHubAnnotationsReporter() if outputFormat == 'annotations' else PrettyReporter()
73-
run_pylint([f'--rcfile={currentDirectory}/pylintrc', targetDirectory], reporter=reporter, exit=False)
74+
pylintConfigFilePath = configFilePath or f'{currentDirectory}/pylintrc'
75+
run_pylint([f'--rcfile={pylintConfigFilePath}', targetDirectory], reporter=reporter, exit=False)
7476
output = reporter.create_output() # type: ignore
7577
if outputFilename:
7678
with open(outputFilename, 'w') as outputFile:

buildpy/type_check.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,15 @@ def create_output(self, messages: List[str]) -> str:
8989
@click.option('-d', '--directory', 'directory', required=False, type=str)
9090
@click.option('-o', '--output-file', 'outputFilename', required=False, type=str)
9191
@click.option('-f', '--output-format', 'outputFormat', required=False, type=str, default='pretty')
92-
def run(directory: str, outputFilename: str, outputFormat: str) -> None:
92+
@click.option('-c', '--config-file-path', 'configFilePath', required=False, type=str)
93+
def run(directory: str, outputFilename: str, outputFormat: str, configFilePath: str) -> None:
9394
currentDirectory = os.path.dirname(os.path.realpath(__file__))
9495
targetDirectory = os.path.abspath(directory or os.getcwd())
9596
reporter = GitHubAnnotationsReporter() if outputFormat == 'annotations' else PrettyReporter()
9697
messages = []
98+
mypyConfigFilePath = configFilePath or f'{currentDirectory}/mypy.ini'
9799
try:
98-
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)
100+
subprocess.check_output(f'mypy {targetDirectory} --config-file {mypyConfigFilePath} --no-color-output --no-error-summary --show-column-numbers', stderr=subprocess.STDOUT, shell=True)
99101
except subprocess.CalledProcessError as exception:
100102
messages = exception.output.decode().split('\n')
101103
output = reporter.create_output(messages=messages) # type: ignore

0 commit comments

Comments
 (0)