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

feat: use literal in type hints #1827

Merged
merged 6 commits into from
Oct 24, 2023

Conversation

bpshaver
Copy link
Contributor

Closes the immediate type issue in #1670

@@ -52,6 +52,10 @@
'pymilvus': '"docarray[milvus]"',
}

ProtocolType = Literal[
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Followed the ALLOWED_PROTOCOLS constant at https://github.com/docarray/docarray/blob/main/docarray/array/doc_list/io.py#L54C1-L54C1

It makes me uncomfortable to define the same information twice, so I can investigate combining the ProtocolType and ALLOWED_PROTOCOLS objects, even though one is a type object and the other is a set of strings.

Copy link
Member

Choose a reason for hiding this comment

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

In a follow-up PR you can define ALLOWED_PROTOCOLS in relation to these types

@@ -52,6 +52,10 @@
'pymilvus': '"docarray[milvus]"',
}

ProtocolType = Literal[
Copy link
Member

Choose a reason for hiding this comment

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

In a follow-up PR you can define ALLOWED_PROTOCOLS in relation to these types

@JoanFM
Copy link
Member

JoanFM commented Oct 23, 2023

Hello @bpshaver,

We need for you to sign off your commits so that we can introduce your contributions. Thanks for the great one btw

@bpshaver
Copy link
Contributor Author

Hello @bpshaver,

We need for you to sign off your commits so that we can introduce your contributions. Thanks for the great one btw

Drats! I signed off on the last commit but not the first two. Let me see about amending the older ones.

Random question: is there a config file mypy should be detecting? I run mypy on the command line and as an LSP, and I'm seeing a lot of errors related to third party libraries that I'm used to ignoring in a config file.

…tocol` parameters

Signed-off-by: Ben Shaver <benpshaver@gmail.com>
Followed the ALLOWED_PROTOCOLS constant at https://github.com/docarray/docarray/blob/main/docarray/array/doc_list/io.py#L54C1-L54C1

Signed-off-by: Ben Shaver <benpshaver@gmail.com>
…rotocolType

Signed-off-by: Ben Shaver <benpshaver@gmail.com>
Signed-off-by: Ben Shaver <benpshaver@gmail.com>
@bpshaver bpshaver force-pushed the feat/#1670/use-literal-in-type-hints branch from 7634fe0 to 61eb05f Compare October 23, 2023 20:27
@bpshaver
Copy link
Contributor Author

@JoanFM Commits are now signed!

Signed-off-by: Ben Shaver <benpshaver@gmail.com>
Signed-off-by: Ben Shaver <benpshaver@gmail.com>
@JoanFM JoanFM changed the title Feat/#1670/use literal in type hints feat: use literal in type hints Oct 23, 2023
@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (d5d928b) 85.04% compared to head (bbb8939) 85.05%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1827   +/-   ##
=======================================
  Coverage   85.04%   85.05%           
=======================================
  Files         135      135           
  Lines        9028     9031    +3     
=======================================
+ Hits         7678     7681    +3     
  Misses       1350     1350           
Flag Coverage Δ
docarray 85.05% <81.81%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
docarray/array/doc_vec/io.py 94.21% <100.00%> (+0.03%) ⬆️
docarray/base_doc/mixins/io.py 90.73% <100.00%> (ø)
docarray/store/helpers.py 60.90% <100.00%> (+0.35%) ⬆️
docarray/utils/_internal/misc.py 66.12% <100.00%> (+0.55%) ⬆️
docarray/array/doc_list/io.py 81.55% <60.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@JohannesMessner
Copy link
Member

Random question: is there a config file mypy should be detecting? I run mypy on the command line and as an LSP, and I'm seeing a lot of errors related to third party libraries that I'm used to ignoring in a config file.

My understanding is that this should be defined in pyprojects.toml.

@JoanFM JoanFM merged commit 522811f into docarray:main Oct 24, 2023
37 of 38 checks passed
@bpshaver bpshaver deleted the feat/#1670/use-literal-in-type-hints branch October 24, 2023 14:27
@JoanFM JoanFM mentioned this pull request Dec 22, 2023
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