Skip to content

Conversation

@zulquer
Copy link
Collaborator

@zulquer zulquer commented May 7, 2025

This pull request includes updates to improve code safety and maintainability by addressing mutable default arguments and refining configuration settings. The most important changes include replacing mutable default arguments with None and handling them safely, as well as updating the pyproject.toml configuration to remove an ignored linting rule.

Code safety improvements:

  • src/multisafepay/api/base/decorator.py: Updated the __init__ method of the Decorator class to replace the mutable default argument dependencies: Dict = {} with dependencies: Dict = None and added logic to initialize it with an empty dictionary if None is provided. [1] [2]
  • src/multisafepay/exception/api.py: Updated the __init__ method of the ApiException class to replace the mutable default argument context: dict = {} with context: dict = None and added logic to initialize it with an empty dictionary if None is provided.

Configuration updates:

  • pyproject.toml: Removed the B006 linting rule from the ignore list, which discourages the use of mutable default arguments in function definitions.

@zulquer zulquer requested a review from Copilot May 7, 2025 09:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses mutable default argument issues and refines configuration settings to improve code safety and maintainability.

  • Updates mutable default parameters in ApiException and Decorator classes to use None safely.
  • Removes the B006 linting rule from the pyproject.toml configuration to enforce proper default value handling.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/multisafepay/exception/api.py Changed mutable default argument for context from {} to None without fallback initialization
src/multisafepay/api/base/decorator.py Replaced mutable default for dependencies with a safe initialization using a ternary operator
pyproject.toml Removed lint rule B006 from the ignore list

self: "ApiException",
message: str,
context: dict = {},
context: dict = None,
Copy link

Copilot AI May 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The init method in ApiException should initialize context with an empty dictionary if None is provided, similar to the approach used in the Decorator class.

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.76%. Comparing base (61bcb14) to head (5027569).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #20   +/-   ##
=======================================
  Coverage   90.76%   90.76%           
=======================================
  Files         106      106           
  Lines        2306     2306           
=======================================
  Hits         2093     2093           
  Misses        213      213           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zulquer zulquer merged commit fdcbfeb into master May 7, 2025
7 checks passed
@zulquer zulquer deleted the PTHMINT-49 branch May 7, 2025 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants