Skip to content

MNT: Privatize Formatter attributes#31416

Merged
QuLogic merged 1 commit intomatplotlib:mainfrom
timhoffm:mnt-deprecate-formatter-attrs
Apr 23, 2026
Merged

MNT: Privatize Formatter attributes#31416
QuLogic merged 1 commit intomatplotlib:mainfrom
timhoffm:mnt-deprecate-formatter-attrs

Conversation

@timhoffm
Copy link
Copy Markdown
Member

These attributes are internal state and users should not access them:

ScalarFormatter.orderOfMagnitude
ScalarFormatter.format
ConciseDateFormatter.offset_format
Formatter.locs

Making them private will allow rearchitecting the handling of tick context (i.e. information extracted from a group of ticks, that may influence their formatting) in the future.

This works towards #31396.

Copy link
Copy Markdown
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

Many internal uses are still not fixed and breaking tests/docs, so I'll mark this as draft.

Comment thread lib/matplotlib/dates.py
'%Y-%b-%d',
'%Y-%b-%d %H:%M']
self.offset_string = ''
self._offset_string = ''
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.

There are still all the internal users of this that aren't converted and will raise a warning.

@QuLogic QuLogic marked this pull request as draft March 30, 2026 19:40
@buddy0452004
Copy link
Copy Markdown
Contributor

hey, I looked into why the tests were failing and it's because the internal usages in ticker.py still reference the old attribute names. I updated all of them locally: self.locs → self._locs across ScalarFormatter, LogitFormatter, EngFormatter and PercentFormatter, self.orderOfMagnitude → self._orderOfMagnitude, and self.format → self._format in ScalarFormatter. sankey.py doesn't need changes since that format attribute belongs to a completely different class. would it be okay if I pushed these fixes to your branch or would you prefer a follow up PR?

@timhoffm
Copy link
Copy Markdown
Member Author

timhoffm commented Apr 8, 2026

@buddy0452004 Thanks for looking into this. Pushing the changes as an additional commit to this branch is welcome.

@buddy0452004
Copy link
Copy Markdown
Contributor

hey, pushed the ticker.py fixes to my fork, opened a PR into your branch here: timhoffm#39

@timhoffm timhoffm marked this pull request as ready for review April 11, 2026 01:57
@timhoffm timhoffm marked this pull request as draft April 11, 2026 07:10
Co-authored-by: buddy0452004 <rahulmonani2004@gmail.com>
@timhoffm timhoffm force-pushed the mnt-deprecate-formatter-attrs branch from 46ee6ca to 791aaf9 Compare April 11, 2026 22:07
@timhoffm timhoffm marked this pull request as ready for review April 11, 2026 22:40
@tacaswell tacaswell added this to the v3.11.0 milestone Apr 23, 2026
@QuLogic QuLogic merged commit 7e18ee2 into matplotlib:main Apr 23, 2026
52 of 53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants