Skip to content

Conversation

@jieter
Copy link
Owner

@jieter jieter commented Nov 6, 2024

Writing union types as X | Y is first added in python 3.10, if we keep supporting it until the end of life of python 3.9, that would mean we can only merge this after 2025-10.

Alternatively, we can use the Union[X, Y] syntax which is already supported by python 3.9.

Another issue is Unpack which is available from python 3.11. It is part of typing_extensions, so we can still use it.

Ideally, users of django-tables2 should still be able to use def render(self, record): or def render(self, value): without complaints of the type checker. I think this might be hard to achieve, so we should document that using def render(self, **kwargs: Unpack[CellArguments]) and unpacking kwargs in the body of the method is the way to achieve type safety.

@jieter jieter force-pushed the feature/util-typing branch from 5e4cec8 to 88f7317 Compare December 21, 2024 10:14
@jieter jieter force-pushed the feature/util-typing branch from f501b82 to 0f7e5be Compare December 21, 2024 13:37
@jieter jieter force-pushed the feature/util-typing branch from b739c27 to 555071a Compare December 23, 2024 08:37
@mschoettle
Copy link
Contributor

With pyupgrade it should be easy to move from Union to | once Python 3.9 support gets dropped. It looks like the pre-commit config needs a small update to target 3.9 instead of 3.8.

@jieter
Copy link
Owner Author

jieter commented Nov 15, 2025

The unions could be removed now that python 3.9 support is dropped. Mypy is satisfied now, the unpacking issue remains.

@jieter jieter changed the title Add typing, remove deprecated RelatedLinkColumn Add typing Nov 22, 2025
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.

3 participants