Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #13 - Fix TypeError when using regexes #14

Merged
merged 1 commit into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion bellybutton/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ def lint(modified_only=False, project_directory='.', verbose=False):
)
for failure in failure_results:
failures += 1
lines = file_contents.splitlines()
print(failure_message.format(
path=relpath,
lineno=failure.lineno,
line=file_contents.splitlines()[failure.lineno - 1],
line=lines[min(failure.lineno, len(lines)) - 1] if lines else '',
rule=failure.rule,
))

Expand Down
2 changes: 1 addition & 1 deletion bellybutton/linting.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def lint_file(filepath, file_contents, rules):
elif isinstance(rule.expr, re._pattern_type):
matching_lines = {
file_contents[:match.start()].count('\n') + 1 # TODO - slow
for match in re.finditer(rule.expr)
for match in re.finditer(rule.expr, file_contents)
}
elif callable(rule.expr):
matching_lines = set(rule.expr(file_contents))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
name='bellybutton',
packages=['bellybutton'],
platforms='any',
version='0.2.1',
version='0.2.2',
description='Custom Python linting through AST expressions.',
author='H. Chase Stevens',
author_email='chase@chasestevens.com',
Expand Down