Skip to content

[Tables] Add __repr__ and __str__ methods to models - #19302

Merged
Sean Kane (seankane-msft) merged 10 commits into
Azure:mainfrom
seankane-msft:tables-repr
Jul 6, 2021
Merged

[Tables] Add __repr__ and __str__ methods to models#19302
Sean Kane (seankane-msft) merged 10 commits into
Azure:mainfrom
seankane-msft:tables-repr

Conversation

@seankane-msft

Copy link
Copy Markdown
Contributor

closes #19278

Will help make debugging easier for us and customers

@ghost

Copy link
Copy Markdown

Hello Sean Kane (@seankane-msft)!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.


def __str__(self):
# type: () -> str
return u"enabled={}, days={}".format(self.enabled, self.days)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

__str__ is not supposed to return unicode. Must be type str

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not sure whether the same applied to __repr__ - would need to check the Py2.7 stdlib ref docs.

Comment thread sdk/tables/azure-data-tables/azure/data/tables/_models.py Outdated
Comment thread sdk/tables/azure-data-tables/azure/data/tables/_models.py Outdated
# type: () -> str
return "version={}, enabled={}, include_apis={}, retention_policy={}".format(
self.version, self.enabled, self.include_apis, self.retention_policy
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm thinking maybe we just don't define __str__ for the time being. Formatting with an instance will default to using __repr__ in the meantime anyway.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I went with this suggestion and removed __str__ methods for now, we can always add them back later.

Comment thread sdk/tables/azure-data-tables/azure/data/tables/_models.py Outdated
@seankane-msft

Copy link
Copy Markdown
Contributor Author

/azp run python - tables - ci

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@seankane-msft
Sean Kane (seankane-msft) merged commit 1ee46b0 into Azure:main Jul 6, 2021
@seankane-msft
Sean Kane (seankane-msft) deleted the tables-repr branch July 6, 2021 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tables] Add __repr__ methods to custom models

3 participants