Skip to content

Conversation

jhaco
Copy link
Owner

@jhaco jhaco commented Dec 2, 2023

No description provided.

@jhaco jhaco linked an issue Dec 2, 2023 that may be closed by this pull request
return note_data, valid

def parse_txt_input(txt_file: list[str]) -> defaultdict(list):
def parse_txt_input(txt_file: list[str]) -> dict[str, dict[str or list[str]] or float or int ]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typing uses the Union operator |

https://peps.python.org/pep-0604/

return sub('4', '1', sub('[MKLF]', '0', line)) #replaces extra notes: M, K, L, F; replaces 4 note

def parse_sm_input(sm_file: list[str]) -> tuple[defaultdict(list), bool]:
def parse_sm_input(sm_file: list[str]) -> tuple[dict[str, dict[str or list[str]] or float or int ], bool]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here

Copy link
Owner Author

Choose a reason for hiding this comment

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

Check my commit message. For Python version <3.10, I have to use OR instead of a Union operator. If you can test it from your end with a Python version 3.10+ and it still works then there shouldn't be any problem.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then Union[x, y, z] from typing should be used instead. As is, I don't think this PR passes pytype checks.

IMO the code base can be upgraded to Python 3.10+. 3.10 has been out for 2 years and it's worth using more modern features.

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 throughout code base
2 participants