Skip to content

Commit

Permalink
loggincase2 (#28)
Browse files Browse the repository at this point in the history
* fail test

* worky

* bump version
  • Loading branch information
haarcuba authored Nov 25, 2024
1 parent 222c7c4 commit 02a97d5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion foxylint/loggingcase.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def __init__(self, file):
self._go()

def _go(self):
BAD_PATTERN = re.compile(r"""(logging|logger)\.(info|warning|error|debug|critical)\(["'][A-Z]""")
BAD_PATTERN = re.compile(r"""(logging|logger)\.(info|warning|error|debug|critical)\([rf]?["'][A-Z]""")
errors = []
with open(self._file) as f:
for line_number, line in enumerate(f, start=1):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "foxylint"
version = "1.3.0"
version = "1.3.1"
description = ""
authors = ["Yoav Kleinberger <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions tests/fixtures/bad.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ def main():
logger.info('I am also bad')
logging.info('I start with a captial letter, that is why I am bad')
logging.info('Another line starts with a capital, this is bad')
logging.info(f'An f-string with a capital letter is bad as well {3.0}')
logging.info(r'An r-string with a capital letter is also bad')
4 changes: 4 additions & 0 deletions tests/test_blackbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ def test_imports(files):
ACCEPTABLE_PATTERNS = [LOGGING_PATTERN]
findings = foxylint.imports.analyze([files.good, files.bad], acceptable_patterns=ACCEPTABLE_PATTERNS)
assert findings[files.good]['ok'] is True
assert len(findings[files.good]['errors']) == 0
assert findings[files.bad]['ok'] is False
assert len(findings[files.bad]['errors']) == 2


def test_loggingcase(files):
findings = foxylint.loggingcase.analyze([files.good, files.bad])
assert findings[files.good]['ok'] is True
assert len(findings[files.good]['errors']) == 0
assert findings[files.bad]['ok'] is False
assert len(findings[files.bad]['errors']) == 5

0 comments on commit 02a97d5

Please sign in to comment.