Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 5, 2024
1 parent 8520328 commit 8af4442
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 38 deletions.
6 changes: 3 additions & 3 deletions server/core/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ def format_message(self, record):
size = record.args.get("size", "UNKNOWN")
else:
# Default values if record.args is not a dictionary
method = (
path
) = status_code = handler_name = duration = remote_addr = size = "UNKNOWN"
method = path = status_code = handler_name = duration = remote_addr = (
size
) = "UNKNOWN"

outcome = (
"Success"
Expand Down
40 changes: 21 additions & 19 deletions server/customer/selectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,31 +303,33 @@ def get_customer_on_time_performance_diff(
"this_month_on_time_percentage": this_month_data["on_time_percentage"],
"last_month_on_time_percentage": last_month_data["on_time_percentage"],
"on_time_diff": (
this_month_data["on_time_percentage"]
- last_month_data["on_time_percentage"]
)
/ last_month_data["on_time_percentage"]
* 100
if last_month_data["on_time_percentage"]
else 0.0,
(
this_month_data["on_time_percentage"]
- last_month_data["on_time_percentage"]
)
/ last_month_data["on_time_percentage"]
* 100
if last_month_data["on_time_percentage"]
else 0.0
),
"this_month_early_percentage": this_month_data["early_percentage"],
"last_month_early_percentage": last_month_data["early_percentage"],
"early_diff": (
this_month_data["early_percentage"] - last_month_data["early_percentage"]
)
/ last_month_data["early_percentage"]
* 100
if last_month_data["early_percentage"]
else 0.0,
(this_month_data["early_percentage"] - last_month_data["early_percentage"])
/ last_month_data["early_percentage"]
* 100
if last_month_data["early_percentage"]
else 0.0
),
"this_month_late_percentage": this_month_data["late_percentage"],
"last_month_late_percentage": last_month_data["late_percentage"],
"late_diff": (
this_month_data["late_percentage"] - last_month_data["late_percentage"]
)
/ last_month_data["late_percentage"]
* 100
if last_month_data["late_percentage"]
else 0.0,
(this_month_data["late_percentage"] - last_month_data["late_percentage"])
/ last_month_data["late_percentage"]
* 100
if last_month_data["late_percentage"]
else 0.0
),
}


Expand Down
18 changes: 9 additions & 9 deletions server/edi/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def validate_server_url(self) -> None:
try:
validator(self.comm_profile.server_url)
except exceptions.ValidationError:
self.errors[
"server_url"
] = f"Invalid URL for protocol {self.comm_profile.protocol}: {self.comm_profile.server_url}"
self.errors["server_url"] = (
f"Invalid URL for protocol {self.comm_profile.protocol}: {self.comm_profile.server_url}"
)

def validate_protocol_mapping(self) -> None:
"""Validates the protocol mapping for port and security expectations based on the EDI communication profile.
Expand Down Expand Up @@ -120,14 +120,14 @@ def validate_protocol_mapping(self) -> None:
self.comm_profile.protocol in secure_protocols
and not self.comm_profile.is_secure
):
self.errors[
"is_secure"
] = f"Protocol {self.comm_profile.protocol} is expected to be secure."
self.errors["is_secure"] = (
f"Protocol {self.comm_profile.protocol} is expected to be secure."
)

if (
self.comm_profile.protocol in insecure_protocols
and self.comm_profile.is_secure
):
self.errors[
"is_secure"
] = f"Protocol {self.comm_profile.protocol} cannot be secure."
self.errors["is_secure"] = (
f"Protocol {self.comm_profile.protocol} cannot be secure."
)
1 change: 1 addition & 0 deletions server/integration/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
You should have received a copy of the GNU General Public License
along with Trenova. If not, see <https://www.gnu.org/licenses/>.
"""

# --------------------------------------------------------------------------------------------------
# COPYRIGHT(c) 2024 Trenova -
# -
Expand Down
9 changes: 6 additions & 3 deletions server/reports/tests/test_user_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ def test_generate_report_task_failure(generate_report: Mock, user: User) -> None
# Mock generate_report to throw an OperationalError
generate_report.side_effect = ServiceException()

with patch(
"reports.tasks.generate_report_task.retry", side_effect=Retry()
) as generate_report_retry, pytest.raises(Retry):
with (
patch(
"reports.tasks.generate_report_task.retry", side_effect=Retry()
) as generate_report_retry,
pytest.raises(Retry),
):
tasks.generate_report_task(
model_name="InvalidModel",
columns=[
Expand Down
8 changes: 5 additions & 3 deletions server/shipment/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@ def gather_formula_variables(*, shipment: models.Shipment) -> types.FormulaVaria
"stops": selectors.get_shipment_stops(shipment=shipment).count(),
"rating_units": shipment.rating_units,
"equipment_cost_per_mile": shipment.equipment_type.cost_per_mile,
"hazmat_additional_cost": shipment.hazardous_material.additional_cost
if shipment.hazardous_material
else 0,
"hazmat_additional_cost": (
shipment.hazardous_material.additional_cost
if shipment.hazardous_material
else 0
),
"temperature_differential": shipment.temperature_differential,
}

Expand Down
4 changes: 3 additions & 1 deletion server/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ class Condition(TypedDict):

class ConditionalLogic(TypedDict):
name: str # Name of conditional logic
description: str # Description of Table Change Alert, conditional Logic is associated with
description: (
str # Description of Table Change Alert, conditional Logic is associated with
)
model_name: str # Table of Table Change Alert, conditional Logic is associated with
app_label: str # App Name the Table Change Table belongs to.
conditions: list[Condition] # List of conditions

0 comments on commit 8af4442

Please sign in to comment.