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

Typing support #1493

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Typing support #1493

wants to merge 9 commits into from

Conversation

palfrey
Copy link

@palfrey palfrey commented Jan 5, 2023

Fixes #1408

This PR does at least an initial pass of adding typing support. Please note it does not support Python 2 at the moment (although that might be getting dropped?) or before 3.5. OTOH, given Python <3.7 is EoL, I don't think they should be supported, but you might want take a different approach, which would need conversion to comment-based typing. This is doable, but a chunk more work and wanted to check if that's needed.

I'd also note that my usual approach on these things is "use the existing CI support for all the version testing" but that doesn't appear to be doable here as it's not setup for that? Relatedly, my formatting is a little wonky, which usually I'd sort out with black, which appears to have been kinda setup and I'd love to get that resolved before this got merged.

It also won't fully work until Avro releases a new version with typing support. Note that this won't change the runtime support requirements, only the requirements if you want to do type checking.

Any thoughts?

@CLAassistant
Copy link

CLAassistant commented Jan 5, 2023

CLA assistant check
All committers have signed the CLA.

@@ -0,0 +1,339 @@
from concurrent.futures import Future
Copy link
Author

Choose a reason for hiding this comment

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

This file is mostly done by stubgen, with some edits where stuff called things and it didn't match up. Note the heavy use of object as a "we don't know what this type is" marker, which mostly should make mypy whinge when it needs more type info and so help us fix it (v.s. using Any)

@palfrey
Copy link
Author

palfrey commented Jan 5, 2023

I'm also seeing unrelated build failures which is always fun :)

@palfrey palfrey mentioned this pull request Jan 5, 2023
7 tasks
@palfrey
Copy link
Author

palfrey commented Jan 6, 2023

I'm also seeing unrelated build failures which is always fun :)

Ah, no wait, my fault. 59f4069 fixes the problem by not using a pyproject.toml as that made pip install do things without the important include paths.

@thanksyouall
Copy link

@palfrey Will you continue this PR? :)

@palfrey
Copy link
Author

palfrey commented Mar 22, 2023

@palfrey Will you continue this PR? :)

Potentially. This is blocked on avro releasing a new version with the changes this needs and ideally on black getting integrated (as was being done in #1352 and then seems to be abandoned). If those get sorted, I can then go through and fix the issues here, but there's no point in repeatedly fixing all the things until then.

@palfrey
Copy link
Author

palfrey commented Mar 22, 2023

And the Python 2 issues getting resolved, ideally by it getting dropped

@Eyal-Shalev
Copy link

@palfrey apache/avro#1952 seems to be merged.

@palfrey
Copy link
Author

palfrey commented May 23, 2023

@palfrey apache/avro#1952 seems to be merged.

But no release (https://github.com/apache/avro/releases) since last August

Copy link

@Viicos Viicos left a comment

Choose a reason for hiding this comment

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

Should we fully parametrize generics with Any? e.g. Sequence[Any] instead of Sequence.

The styling standard regarding default values is to add spaces around the = char: arg: Optional[str] = None

@@ -108,13 +107,13 @@ def produce(self, **kwargs):
else:
raise ValueSerializerError("Avro schema required for values")

if key is not None:
if key is not None:
Copy link

Choose a reason for hiding this comment

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

Suggested change
if key is not None:
if key is not None:

Copy link
Author

Choose a reason for hiding this comment

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

There's a lot of issues like this, and I'd mostly filed them under "get black fixed". See #1352 and #1493 (comment)

Copy link

Choose a reason for hiding this comment

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

Ah yes makes sense. Unfortunately maintainers don't seem pretty active

Copy link
Author

Choose a reason for hiding this comment

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

Sadly, yes. Ironically, I'm job hunting at the moment, and had applied to Confluent but they were looking mostly for Java devs IIRC :( If they wanted to employ me to fix these things that might speed things up a lot...

Copy link

Choose a reason for hiding this comment

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

If they wanted to employ me to fix these things that might speed things up a lot...

Oh please ! This project is half-dead and Confluent is a commercial entity.

@cameronbrill
Copy link

@palfrey apache/avro#1952 seems to be merged.

But no release (apache/avro/releases) since last August

just FYI avro finally published a release 2 days ago!

@palfrey palfrey marked this pull request as ready for review July 16, 2023 22:26
@palfrey palfrey requested a review from a team as a code owner July 16, 2023 22:26
@hantonelli
Copy link

hantonelli commented Sep 25, 2023

Is this PR going to be merged soon? Is there any blocker or changes left before merging this?
@palfrey Do you need to sign the Contributor License Agreement?

@palfrey
Copy link
Author

palfrey commented Sep 25, 2023

Is this PR going to be merged soon? Is there any blocker or changes left before merging this? @palfrey Do you need to sign the Contributor License Agreement?

Didn't know there was a CLA and TBH I wouldn't have done this if I'd known about it, but signed now. Waiting on review.

@cameronbrill
Copy link

cc @jkuhnashconfluent @emasab @pranavrth for review since you three were on the last PRs to be merged into this repo.

@hantonelli
Copy link

@joaoe @Viicos are you the ones that are need to review this or is someone else?

@Viicos
Copy link

Viicos commented Oct 3, 2023

@joaoe @Viicos are you the ones that are need to review this or is someone else?

I'm not a maintainer of the repo, so I can't do much. If you get no answers from them, the backup plan would be to create stubs but this is generally not the prefered way

@pranavrth
Copy link
Member

Hey Guys,

Sorry for the late reply. We couldn't pay much attention to this PR.

This is an important PR which we would like to incorporate in our client. I will try to get some time in coming weeks for reviewing this PR.

@palfrey
Copy link
Author

palfrey commented Nov 18, 2023

Hey Guys,

Sorry for the late reply. We couldn't pay much attention to this PR.

This is an important PR which we would like to incorporate in our client. I will try to get some time in coming weeks for reviewing this PR.

How's that going?

@lannuttia
Copy link

It's a shame that all of this work has been done and the "coming weeks" has slowly turned into 4 and a half months. I fear that if this sits much longer, this contribution will start to grow stale and require additional work to get in a state that it can be merged again. I think having type hints is exceptionally valuable not just for the maintenance of this project but also the maintenance of any projects that consume this library and I would love to see merging this PR find its way back onto Confluent Inc's list of priorities.

@palfrey
Copy link
Author

palfrey commented Feb 29, 2024

I fear that if this sits much longer, this contribution will start to grow stale and require additional work to get in a state that it can be merged again.

I'm mostly willing to do the work to un-stale it, but only when I know there will actually be review and possible merge of it, and I'm otherwise ignoring conflicts until that point. If I'd seen a first round of review that at least looked at what was done so far (and ideally also addressed the Python versioning and black issues) then I'd come back to this, but so far I'm seeing no indications of this actually occuring any time soon despite prior comments on this PR.

@Eyal-Shalev
Copy link

@palfrey have you considered moving the effort to Typeshed?

I don't know what it entails but if I understand correctly it will actually have a chance to be merged 😔

@palfrey
Copy link
Author

palfrey commented Mar 13, 2024

@palfrey have you considered moving the effort to Typeshed?

I don't know what it entails but if I understand correctly it will actually have a chance to be merged 😔

I hadn't. It's a fair amount of work (ripping out the types from the individual .py files and redoing as just the signatures in .pyi files), and TBH, I'm not exactly enthused about that, especially as I don't use the library currently. If this comes back to life, I'm willing to fix things here though.

OTOH, if anyone else wants to take what I've done here and do that work in Typeshed, awesome. Some level of credit/mention would be appreciated, but otherwise, go for it!

@Barabazs
Copy link

I hadn't. It's a fair amount of work (ripping out the types from the individual .py files and redoing as just the signatures in .pyi files)

I think it should be possible to automate this with stubgen.

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.

Add typing support