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

enhanced the default datetimeformatter with a dynamic one #13854

Open
wants to merge 2 commits into
base: branch-3.5
Choose a base branch
from

Conversation

muendlein
Copy link
Contributor

All pull requests must have an associated issue in the issue tracker. If there
isn't one, please go open an issue describing the defect, deficiency or desired
feature. You can read more about our issue and PR processes in the
wiki.

Copy link

codecov bot commented Apr 29, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 92.64%. Comparing base (e61219b) to head (bcf1285).
Report is 20 commits behind head on branch-3.5.

Additional details and impacted files
@@              Coverage Diff               @@
##           branch-3.5   #13854      +/-   ##
==============================================
+ Coverage       91.57%   92.64%   +1.06%     
==============================================
  Files             326      326              
  Lines           20737    20765      +28     
==============================================
+ Hits            18990    19237     +247     
+ Misses           1747     1528     -219     

@bryevdv
Copy link
Member

bryevdv commented Apr 29, 2024

Unfortunately, this will take more work / different approach. The issue is that the way things are done in the PR, every single axis has a different DatetimeTickFormatter instance, but all of those share one single "global" DatetimeTickFormatter for their context. That won't work.

An immediate solution could be get rid of InstanceDefault and just pass the callable DYNAMIC_DATETIME_FORMATTER for the value. That would allow for every axis to get all new unique objects. But then the ref docs will suffer, because rendering these kinds of "dynamic" defaults better is what InstanceDefault was added for.

Or perhaps InstanceDefault can be made more sophisticated in some way, but that will require new development.

@muendlein
Copy link
Contributor Author

@bryevdv Thanks for pointing out the sided effects. However I am wondering if there have been similar cases in the past or is this the first one?
As for moving forward, do you consider your proposed immediate solution as an viable option (given the downsides)?

@bryevdv
Copy link
Member

bryevdv commented Apr 30, 2024

It's not common to have dynamic defaults, less common still have to have dynamic defaults that are model instances, and among that tiny set, I do believe this would be the first time ever a dynamic instance default itself had property that was also such.

I think you should try building without InstanceDefault, and then also build the docs to see how badly things render in the reference guide. If it's just some opaque but short repr that shows up, that's probably fine. If it's some giant mess that takes up half the page looking like a C++ error message, that is probably not fine.

@muendlein
Copy link
Contributor Author

@bryevdv Building without InstanceDefault works out fine. When building the docs there aren't any rendering issues but of course the static (and therefore wrong) default values are shown.

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.

[FEATURE] datetime formatting: enhance default formatting
2 participants