Skip to content

Commit a9c614d

Browse files
wip
1 parent 4b437f3 commit a9c614d

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ dev-test:
8787
@echo "$(OK_COLOR)=> Running unit tests in directory $(PWD) $(NO_COLOR)"
8888
pytest tests/ --cov $(PACKAGE_NAME) --cov-report=xml
8989

90+
dev-lint-report:
91+
@echo "$(OK_COLOR)=> Running Prospector lint reporting $(PWD) $(NO_COLOR)"
92+
prospector --profile prospector.yaml > prospector_report.txt
93+
94+
dev-lint:
95+
@echo "$(OK_COLOR)=> Running Prospector lint reporting $(PWD) $(NO_COLOR)"
96+
prospector --profile prospector.yaml
97+
9098
dev-test-with-html-report:
9199
@echo "$(OK_COLOR)=> Running unit tests with HTML test coverage report$(NO_COLOR)"
92100
pytest --cov $(PACKAGE_NAME) --cov-report html -s

prospector.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ pylint:
3333
- too-many-branches
3434
- unnecessary-lambda
3535
- unused-variable # TBD: this rule is actually a good one, we need to disable it and refactor code
36+
- logging-fstring-interpolation # using f-strings for logging where cost of computing string is low
37+
- unnecessary-lambda-assignment # in some cases, prefer using lambda rather than function for clarity / conciseness
38+
- redefined-outer-name # pylint flags use of pytest fixtures as redefinition
3639

3740
pyflakes:
3841
disable:
@@ -53,6 +56,7 @@ pep8:
5356
- E128 # formatting only
5457
- E126 # formatting only
5558
- N815 # disabled as we use mixed case names following pyspark convention
59+
- E731 # prefer use of lambda in some cases for clarity / conciseness
5660

5761
mccabe:
5862
disable:

tests/test_text_templates.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,14 @@ def test_rnd_compute(self, templateProvided, escapeSpecial, useTemplateObject):
124124
assert len(template_choices) == len(template_rnds)
125125
assert len(template_choices) == len(template_rnd_bounds)
126126

127-
for ix in range(len(template_choices)):
127+
for ix, _ in enumerate(template_choices):
128128
bounds = template_rnd_bounds[ix]
129129
rnds = template_rnds[ix]
130130

131131
assert len(bounds) == len(rnds)
132132

133-
for iy in range(len(bounds)):
134-
assert bounds[iy] == -1 or (rnds[iy] < bounds[iy])
133+
for iy, bounds_value in enumerate(bounds):
134+
assert bounds_value == -1 or (rnds[iy] < bounds_value)
135135

136136
@pytest.mark.parametrize("templateProvided, escapeSpecial, useTemplateObject",
137137
[ # (r'\w \w|\w \v. \w', False, False),
@@ -221,14 +221,14 @@ def test_use_pandas(self, templateProvided, escapeSpecial, useTemplateObject):
221221
assert len(template_choices) == len(template_rnds)
222222
assert len(template_choices) == len(template_rnd_bounds)
223223

224-
for ix in range(len(template_choices)):
224+
for ix, _ in enumerate(template_choices):
225225
bounds = template_rnd_bounds[ix]
226226
rnds = template_rnds[ix]
227227

228228
assert len(bounds) == len(rnds)
229229

230-
for iy in range(len(bounds)):
231-
assert bounds[iy] == -1 or (rnds[iy] < bounds[iy])
230+
for iy, bounds_value in enumerate(bounds):
231+
assert bounds_value == -1 or (rnds[iy] < bounds_value)
232232

233233
results = template1.pandasGenerateText(arr)
234234
assert results is not None
@@ -238,14 +238,13 @@ def test_use_pandas(self, templateProvided, escapeSpecial, useTemplateObject):
238238
results_rows = len(results_list)
239239
assert results_rows == TEST_ROWS
240240

241-
for r in range(len(results)):
242-
result_str = results[r]
241+
for r, result_str in enumerate(results):
243242
assert result_str is not None and isinstance(result_str, str)
244243
assert len(result_str) >= 0
245244

246245
print("results")
247-
for i in range(len(results)):
248-
print(f"{i}: '{results[i]}'")
246+
for i, result_value in enumerate(results):
247+
print(f"{i}: '{result_value}'")
249248

250249
@pytest.mark.parametrize("templateProvided, escapeSpecial, useTemplateObject",
251250
[(r'\n', False, True),
@@ -270,14 +269,14 @@ def test_sub_value1(self, templateProvided, escapeSpecial, useTemplateObject):
270269
assert len(template_choices) == len(template_rnds)
271270
assert len(template_choices) == len(template_rnd_bounds)
272271

273-
for ix in range(len(template_choices)):
272+
for ix, _ in enumerate(template_choices):
274273
bounds = template_rnd_bounds[ix]
275274
rnds = template_rnds[ix]
276275

277276
assert len(bounds) == len(rnds)
278277

279-
for iy in range(len(bounds)):
280-
assert bounds[iy] == -1 or (rnds[iy] < bounds[iy])
278+
for iy, bounds_value in enumerate(bounds):
279+
assert bounds_value == -1 or (rnds[iy] < bounds_value)
281280

282281
results = template1.pandasGenerateText(arr)
283282
assert results is not None
@@ -287,14 +286,13 @@ def test_sub_value1(self, templateProvided, escapeSpecial, useTemplateObject):
287286
results_rows = len(results_list)
288287
assert results_rows == TEST_ROWS
289288

290-
for r in range(len(results)):
291-
result_str = results[r]
289+
for r, result_str in enumerate(results):
292290
assert result_str is not None and isinstance(result_str, str)
293291
assert len(result_str) >= 0
294292

295293
print("results")
296-
for i in range(len(results)):
297-
print(f"{i}: '{results[i]}'")
294+
for i, result_value in enumerate(results):
295+
print(f"{i}: '{result_value}'")
298296

299297
@pytest.mark.parametrize("templateProvided, escapeSpecial, useTemplateObject",
300298
[(r'\w aAdDkK \w', False, False),

0 commit comments

Comments
 (0)