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

Introduce more Ruff rules to improve code quality #69

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

corafid
Copy link
Member

@corafid corafid commented Dec 17, 2024

To ensure high code quality and capture accidental issues at build time rather the run time, I am extending the Ruff rules enabled.

@corafid corafid requested a review from a team as a code owner December 17, 2024 19:36
@corafid corafid merged commit 72f74f5 into main Dec 18, 2024
11 checks passed
@corafid corafid deleted the corafid/feat/more-ruff-rules branch December 18, 2024 01:02
recursive: bool = False,
) -> List[str]:
) -> list[str]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we changing this to list, i thought python preferred way is typing.List

Copy link
Member Author

Choose a reason for hiding this comment

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

@ankush-cohere

TL;DR - list is the recommended way starting from Python 3.9.

typing.List isn't actually the preferred. When type hinting was introduced in Python (in version 3.5), it was straight forward to support primitive types like int, float in a "natural way", i.e. using the types themselves without having to define a parallel type under the contrived typing module. However, generic types like list, dict was a bit more challenging to introduce, and hence the Python community introduced the typing model to address the challenges. But after PEP 585, which was introduced in Python 3.9, it became possible to use the types directly, i.e. list, dict, etc., without having to define a parallel type in the typing module. Hence, types like typing.Dict, typing.List, etc., are now unnecessary and they are getting deprecated and will be removed in future versions of Python; see the doc.

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