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

Support property attributes in repr of BaseMixin #469

Merged
merged 5 commits into from
Sep 5, 2024
Merged

Conversation

egoriyaa
Copy link
Collaborator

@egoriyaa egoriyaa commented Sep 3, 2024

Before submitting (must do checklist)

  • Did you read the contribution guide?
  • Did you update the docs? We use Numpy format for all the methods and classes.
  • Did you write any new necessary tests?
  • Did you update the CHANGELOG?

Proposed Changes

Closing issues

closes #467

@egoriyaa egoriyaa self-assigned this Sep 3, 2024
Copy link

github-actions bot commented Sep 3, 2024

🚀 Deployed on https://deploy-preview-469--etna-docs.netlify.app

@github-actions github-actions bot temporarily deployed to pull request September 3, 2024 18:50 Inactive
Copy link

codecov bot commented Sep 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.60%. Comparing base (7dbbf50) to head (993f6f5).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #469      +/-   ##
==========================================
- Coverage   90.62%   90.60%   -0.02%     
==========================================
  Files         247      247              
  Lines       16481    16481              
==========================================
- Hits        14936    14933       -3     
- Misses       1545     1548       +3     

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

@egoriyaa egoriyaa changed the title Support property attributes in repr of BaseMixin Support property attributes in repr of BaseMixin Sep 3, 2024
CHANGELOG.md Outdated
@@ -29,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-

### Changed
-
- Add support of property attributes in `__repr__` of `BaseMixin` ([#469](https://github.com/etna-team/etna/pull/469))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not only __repr__, but also to_dict.

@@ -32,11 +32,11 @@ def __repr__(self):
if param.kind == param.VAR_POSITIONAL:
continue
elif param.kind == param.VAR_KEYWORD:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's create some basic tests on working with BaseMixin. The methods to functionality to check is:

  • repr
    • Add test on dummy class with private attribute and public property
  • to_dict
    • We already have file test_to_dict, let's add new tests here
    • Add test on dummy class with private attribute and public property
  • set_params
    • We already have file test_set_params, let's add new tests here
    • Add test on dummy class with private attribute and public property

@@ -130,3 +131,11 @@ def test_update_nested_structure(nested_structure, keys, value, expected_result)
def test_update_nested_structure_fail(nested_structure, keys, value):
with pytest.raises(ValueError, match=f"Structure to update is .* with type .*"):
_ = BaseMixin._update_nested_structure(nested_structure, keys, value)


def test_to_dict_public_property_private_attribute():
Copy link
Collaborator

Choose a reason for hiding this comment

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

The name of the test could be changed.

@github-actions github-actions bot temporarily deployed to pull request September 4, 2024 15:42 Inactive


def test_to_dict_public_property_private_attribute():
dummy = Dummy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's may be set some values for a and b here for better inspectability.



def test_to_dict_public_property_private_attribute():
dummy = Dummy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's may be set some values for a and b here for better inspectability.



def test_repr_public_property_private_attribute():
dummy = Dummy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's may be set some values for a and b here for better inspectability.

from etna.core.mixins import BaseMixin


class Dummy(BaseMixin):
Copy link
Collaborator

Choose a reason for hiding this comment

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

May be we could name it somewhat more specific like: BaseDummy to be related to BaseMixin.

Egor Baturin added 2 commits September 4, 2024 21:53
@github-actions github-actions bot temporarily deployed to pull request September 4, 2024 18:59 Inactive
@egoriyaa egoriyaa merged commit 72ab4dd into master Sep 5, 2024
17 checks passed
@egoriyaa egoriyaa deleted the issue-467 branch September 9, 2024 12:59
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.

Support property attributes in repr of BaseMixin
2 participants