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

Add type annotations to xml.py #1327

Merged
merged 14 commits into from
Nov 22, 2023
Merged

Add type annotations to xml.py #1327

merged 14 commits into from
Nov 22, 2023

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Nov 9, 2023

No description provided.

@trim21 trim21 changed the title Add type annotations and import typing module to xml.py Add type annotations to xml.py Nov 9, 2023
@trim21

This comment was marked as off-topic.

Copy link
Member

@balamurugana balamurugana left a comment

Choose a reason for hiding this comment

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

Duck typing in this PR is incomplete. Please fix accordingly.

@trim21
Copy link
Contributor Author

trim21 commented Nov 20, 2023

Duck typing in this PR is incomplete. Please fix accordingly.

Sorry, which class/function are you referring to? IFromXML and IToXML are incomplete?

your review comment didn't attach to any line of files.

@balamurugana
Copy link
Member

Duck typing in this PR is incomplete. Please fix accordingly.

Sorry, which class do you mean? IFromXML and IToXML are incomplete?

Code in xml.py

@trim21
Copy link
Contributor Author

trim21 commented Nov 20, 2023

Duck typing in this PR is incomplete. Please fix accordingly.

Sorry, which class do you mean? IFromXML and IToXML are incomplete?

Code in xml.py

done

minio/xml.py Outdated Show resolved Hide resolved
@@ -80,20 +92,43 @@ def findtext(element, name, strict=False):
return element.text or ""


def unmarshal(cls, xmlstring):
K = TypeVar("K")
Copy link
Member

Choose a reason for hiding this comment

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

Have meaningful name here

Copy link
Contributor Author

@trim21 trim21 Nov 21, 2023

Choose a reason for hiding this comment

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

this is generic type parameter, it's custom to be named as T K J。it's like i x,y in looping.

minio/xml.py Outdated Show resolved Hide resolved
minio/xml.py Outdated Show resolved Hide resolved
minio/xml.py Outdated Show resolved Hide resolved
data, encoding=None, xml_declaration=False,
)
return data.getvalue()
with io.BytesIO() as data:
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to use with here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

close file and discard the buffer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not necessary, gc will handle them if we don't use with

Copy link
Member

Choose a reason for hiding this comment

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

Yep. For this function, it is unnecessary.

data, encoding=None, xml_declaration=False,
)
return data.getvalue()
with io.BytesIO() as data:
Copy link
Member

Choose a reason for hiding this comment

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

Yep. For this function, it is unnecessary.

minio/xml.py Outdated Show resolved Hide resolved
minio/xml.py Outdated Show resolved Hide resolved
@harshavardhana harshavardhana merged commit 8dce506 into minio:master Nov 22, 2023
15 checks passed
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