René's URL Explorer Experiment


Title: Fix add_vline and add_hline with datetime axes by mosh3eb · Pull Request #5508 · plotly/plotly.py · GitHub

Open Graph Title: Fix add_vline and add_hline with datetime axes by mosh3eb · Pull Request #5508 · plotly/plotly.py

X Title: Fix add_vline and add_hline with datetime axes by mosh3eb · Pull Request #5508 · plotly/plotly.py

Description: Summary When using add_vline, add_hline, add_vrect, or add_hrect with annotation_text on datetime axes, plotly crashes with a TypeError because the _mean() helper function tries to call float(sum(x)) on datetime strings. Approach Instead of assuming input values are equal (which only works for vlines/hlines), _mean() now converts datetime-like values to milliseconds-since-epoch, computes the actual arithmetic mean, and converts back. This correctly handles annotation placement for ALL shapes with datetime axes, including rects where x0 != x1. The numeric fast path is unchanged -- datetime handling only activates when sum() raises TypeError Handles both date strings ("2018-09-24") and datetime.datetime objects Re-raises TypeError for truly unsupported types Changes plotly/shapeannotation.py: Added _is_date_string(), _datetime_str_to_ms(), _ms_to_datetime_str() helpers and updated _mean() with try/except fallback tests/test_optional/test_autoshapes/test_annotated_shapes.py: Added 5 tests covering datetime strings, datetime objects, vlines, hlines, and vrects Fixes #3065

Open Graph Description: Summary When using add_vline, add_hline, add_vrect, or add_hrect with annotation_text on datetime axes, plotly crashes with a TypeError because the _mean() helper function tries to call float(sum(x...

X Description: Summary When using add_vline, add_hline, add_vrect, or add_hrect with annotation_text on datetime axes, plotly crashes with a TypeError because the _mean() helper function tries to call float(sum(x...

Opengraph URL: https://github.com/plotly/plotly.py/pull/5508

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:83c3b34f-9315-0d4a-35df-b9ac0131e852
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idBF84:1EFF29:207B0E2:2BE73DE:6A65588A
html-safe-nonce2bd93d77800f87923fa54456e7a6a89d5180262a8b24f57eb7b6ff1868942e37
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRjg0OjFFRkYyOToyMDdCMEUyOjJCRTczREU6NkE2NTU4OEEiLCJ2aXNpdG9yX2lkIjoiODY2OTAyODc5MTY1Nzc4MTM4NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacff609fb19cedf04dba146c687f24ddefe7d35c0c27cf4013c0f3e0d3db1c35f4
hovercard-subject-tagpull_request:3283796011
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
twitter:imagehttps://avatars.githubusercontent.com/u/68575768?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/68575768?s=400&v=4
og:image:altSummary When using add_vline, add_hline, add_vrect, or add_hrect with annotation_text on datetime axes, plotly crashes with a TypeError because the _mean() helper function tries to call float(sum(x...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git
octolytics-dimension-user_id5997976
octolytics-dimension-user_loginplotly
octolytics-dimension-repository_id14579099
octolytics-dimension-repository_nwoplotly/plotly.py
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id14579099
octolytics-dimension-repository_network_root_nwoplotly/plotly.py
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fplotly%2Fplotly.py%2Fpull%2F5508%2Fcommits%2F9bed9d301e2487a1b758a73c33c5861865995855
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fplotly%2Fplotly.py%2Fpull%2F5508%2Fcommits%2F9bed9d301e2487a1b758a73c33c5861865995855
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=plotly%2Fplotly.py
Reloadhttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Reloadhttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Reloadhttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
plotly https://github.com/plotly
plotly.pyhttps://github.com/plotly/plotly.py
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Notifications https://github.com/login?return_to=%2Fplotly%2Fplotly.py
Fork 2.8k https://github.com/login?return_to=%2Fplotly%2Fplotly.py
Star 18.7k https://github.com/login?return_to=%2Fplotly%2Fplotly.py
Code https://github.com/plotly/plotly.py
Issues 722 https://github.com/plotly/plotly.py/issues
Pull requests 56 https://github.com/plotly/plotly.py/pulls
Actions https://github.com/plotly/plotly.py/actions
Security and quality 0 https://github.com/plotly/plotly.py/security
Insights https://github.com/plotly/plotly.py/pulse
Code https://github.com/plotly/plotly.py
Issues https://github.com/plotly/plotly.py/issues
Pull requests https://github.com/plotly/plotly.py/pulls
Actions https://github.com/plotly/plotly.py/actions
Security and quality https://github.com/plotly/plotly.py/security
Insights https://github.com/plotly/plotly.py/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fplotly%2Fplotly.py%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fplotly%2Fplotly.py%2Fissues%2Fnew%2Fchoose
emilyklhttps://github.com/emilykl
plotly:mainhttps://github.com/plotly/plotly.py/tree/main
mosh3eb:fix/add-vline-datetime-annotationhttps://github.com/mosh3eb/plotly.py/tree/fix/add-vline-datetime-annotation
Conversation 13 https://github.com/plotly/plotly.py/pull/5508
Commits 6 https://github.com/plotly/plotly.py/pull/5508/commits
Checks 24 https://github.com/plotly/plotly.py/pull/5508/checks
Files changed 2 https://github.com/plotly/plotly.py/pull/5508/files
Fix add_vline and add_hline with datetime axes https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#top
Show all changes 6 commits https://github.com/plotly/plotly.py/pull/5508/files
9bed9d3 Fix _mean() to handle datetime values for shape annotations mosh3eb Feb 20, 2026 https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
2cf036c Merge branch 'main' into fix/add-vline-datetime-annotation emilykl May 8, 2026 https://github.com/plotly/plotly.py/pull/5508/commits/2cf036c8a5b276d3b1e22944359a9a48ecfe5432
b83c5ad Assert annotation x-position in tests emilykl May 8, 2026 https://github.com/plotly/plotly.py/pull/5508/commits/b83c5addd60659cae44aa1baa3f5aabbe12bdf1b
82e5759 formatting emilykl May 8, 2026 https://github.com/plotly/plotly.py/pull/5508/commits/82e5759028938b2cdbf2fce965f9233436f91280
05ac018 formatting emilykl May 8, 2026 https://github.com/plotly/plotly.py/pull/5508/commits/05ac01868edd79752151c6e2e72853d9d65a01e2
8c18945 formatting emilykl May 8, 2026 https://github.com/plotly/plotly.py/pull/5508/commits/8c18945fb61b57e255683ee0c0d82f41bbcef32b
Clear filters https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
shapeannotation.py https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#diff-d8da746d071f9f9993bbab6a20424e54fc0efae9efe056c664b037a626139778
test_annotated_shapes.py https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#diff-80d52795898ac1071de78a9495e1e88a66f8e35827eca15d354c96db2baed067
Next https://github.com/plotly/plotly.py/pull/5508/commits/2cf036c8a5b276d3b1e22944359a9a48ecfe5432
#3065https://github.com/plotly/plotly.py/issues/3065
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
https://github.com/mosh3eb
mosh3ebhttps://github.com/plotly/plotly.py/commits?author=mosh3eb
plotly/shapeannotation.pyhttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#diff-d8da746d071f9f9993bbab6a20424e54fc0efae9efe056c664b037a626139778
View file https://github.com/mosh3eb/plotly.py/blob/9bed9d301e2487a1b758a73c33c5861865995855/plotly/shapeannotation.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/plotly/plotly.py/pull/5508/commits/{{ revealButtonHref }}
https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#diff-d8da746d071f9f9993bbab6a20424e54fc0efae9efe056c664b037a626139778
tests/test_optional/test_autoshapes/test_annotated_shapes.pyhttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#diff-80d52795898ac1071de78a9495e1e88a66f8e35827eca15d354c96db2baed067
View file https://github.com/mosh3eb/plotly.py/blob/9bed9d301e2487a1b758a73c33c5861865995855/tests/test_optional/test_autoshapes/test_annotated_shapes.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/plotly/plotly.py/pull/5508/commits/{{ revealButtonHref }}
https://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855#diff-80d52795898ac1071de78a9495e1e88a66f8e35827eca15d354c96db2baed067
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
Please reload this pagehttps://github.com/plotly/plotly.py/pull/5508/commits/9bed9d301e2487a1b758a73c33c5861865995855
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.