Skip to content

Commit 3933a4c

Browse files
committed
Pylint
1 parent ff47aa2 commit 3933a4c

File tree

3 files changed

+31
-17
lines changed

3 files changed

+31
-17
lines changed

popsborder/effectiveness.py

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
# Simulation of contaminated consignments and their inspections
2+
# Copyright (C) 2018-2022 Vaclav Petras and others (see below)
3+
4+
# This program is free software; you can redistribute it and/or modify it under
5+
# the terms of the GNU General Public License as published by the Free Software
6+
# Foundation; either version 2 of the License, or (at your option) any later
7+
# version.
8+
9+
# This program is distributed in the hope that it will be useful, but WITHOUT
10+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12+
# details.
13+
14+
# You should have received a copy of the GNU General Public License along with
15+
# this program; if not, see https://www.gnu.org/licenses/gpl-2.0.html
16+
17+
"""Effectiveness configuration and validation"""
18+
19+
120
def validate_effectiveness(config, verbose=False):
221
"""Set the effectiveness of the inspector.
322
@@ -7,20 +26,16 @@ def validate_effectiveness(config, verbose=False):
726
:param config: Configuration file
827
:param verbose: Print the message if True
928
"""
10-
try:
11-
if isinstance(config, dict):
12-
effectiveness = 1
13-
if "effectiveness" in config["inspection"]:
14-
if 0 <= config["inspection"]["effectiveness"] <= 1:
15-
effectiveness = config["inspection"]["effectiveness"]
16-
else:
17-
if verbose:
18-
print(
19-
"Effectiveness out of range: it should be between "
20-
"0 and 1."
21-
)
29+
effectiveness = 1
30+
31+
if isinstance(config, dict):
32+
if "effectiveness" in config["inspection"]:
33+
if 0 <= config["inspection"]["effectiveness"] <= 1:
34+
effectiveness = config["inspection"]["effectiveness"]
2235
else:
2336
if verbose:
24-
print("Effectiveness not set in the configuration file.")
25-
finally:
26-
return effectiveness
37+
print(
38+
"Effectiveness out of range: it should be between "
39+
"0 and 1."
40+
)
41+
return effectiveness

popsborder/inspections.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ def inspect(config, consignment, n_units_to_inspect, detailed):
435435
config, consignment, n_units_to_inspect
436436
)
437437

438-
# TODO May not be needing this if default effectiveness is added to config.
439438
effectiveness = validate_effectiveness(config)
440439

441440
# Inspect selected boxes, count opened boxes, inspected items,

tests/test_effectiveness.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
items_inspected_detection=0,
6565
contaminated_items_completion=0,
6666
contaminated_items_detection=0,
67-
contaminated_items_missed=0
67+
contaminated_items_missed=0,
6868
)
6969

7070
config = load_configuration_yaml_from_text(CONFIG)

0 commit comments

Comments
 (0)