Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding DictConfig #498

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Adding DictConfig #498

wants to merge 7 commits into from

Conversation

SalvatoreZagaria
Copy link

Pull Request Description

This pull request includes new features for configuring retry parameters using the DictConfig class.

Summary of Changes:

  1. Add Unit Tests for Tenacity's Default Configurations:

    • Introduced a new test class TestRetryDefaults to validate the functionalities of dict_config within tenacity.
    • Created unit tests that cover:
      • Setting, getting, overriding, and deleting configuration attributes.
      • Testing retry behavior with both default and overridden configurations.
  2. Refactor Configuration Handling:

    • Removed redundant attribute checks in the __init__ method and simplified its initialization.
    • Added a new get method to access configuration values more explicitly and efficiently.
  3. Add Configurable Retry Parameters with DictConfig:

    • Introduced a DictConfig class to manage default retry parameters in a singleton dictionary.
    • Enhanced flexibility by allowing default configurations to be overridden or extended when calling the retry decorator.

This is addressing issue #495

Introduce a DictConfig class to manage default retry parameters in a singleton dictionary. Enhances flexibility by allowing default configurations to be overridden or extended when calling the retry decorator.
Remove redundant attribute check in __init__ method and simplify its initialization. Add a new `get` method to access configuration values more explicitly and efficiently.
This commit introduces a new test class `TestRetryDefaults` to verify `dict_config` functionalities within tenacity. Included tests cover setting, getting, overriding, and deleting configuration attributes, as well as testing retry behavior with default and overridden configurations.
Copy link
Contributor

mergify bot commented Sep 28, 2024

⚠️ No release notes detected. Please make sure to use reno to add a changelog entry.

Reformatted function calls and comments across `tests/test_tenacity.py` and `tenacity/config.py` for consistent indentation and alignment. This improves the code's readability and maintainability.
Introduced the `DictConfig` class to manage default retry parameters in a singleton dictionary. Refactored initialization methods, adding a new `get` method for better configuration access. Included a new test class `TestRetryDefaults` to verify `dict_config` functionalities.
Converted multi-line entries in release notes to single-line with quotes. This improves readability and maintains consistency across the document. Reduced redundancy in formatting for a cleaner output.
Updated the singleton implementation and added type annotations to various methods and attributes in the DictConfig class. This improves code readability and helps with static type checking.
Copy link
Owner

@jd jd left a comment

Choose a reason for hiding this comment

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

I don't think this is an infrastructure we want to offer in tenacity.

@tk512
Copy link

tk512 commented Oct 8, 2024

I don't think this is an infrastructure we want to offer in tenacity.

Is there another way / a compromise for this to be supported by Tenacity? I think it would be highly useful to have safer retry defaults, for one. Perhaps configurable via pyproject.toml as well.

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.

3 participants