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

[fpdf2] fix link type to support internal links #12695

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

mschoettle
Copy link
Contributor

Methods with the link argument can take an internal link (created via add_link which returns an int) or an external URL as per their docstring.

The type hint only allows for str.

link already has the correct type hint:

def link(
self, x: float, y: float, w: float, h: float, link: str | int, alt_text: str | None = None, border_width: int = 0
) -> AnnotationDict: ...

add_link returns an int:

def add_link(self, y: float = 0, x: float = 0, page: int = -1, zoom: float | Literal["null"] = "null") -> int: ...

This PR changes the type hint to str | int.

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

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

Thanks!

@srittau srittau merged commit 283ff95 into python:main Sep 26, 2024
48 checks passed
@mschoettle mschoettle deleted the fpdf-link branch October 22, 2024 00:44
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.

2 participants