-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Better pipeline type hints ✨ #38049
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
base: main
Are you sure you want to change the base?
Better pipeline type hints ✨ #38049
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
The code is a bit bloated, but since |
@@ -12,7 +12,7 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
import subprocess | |||
from typing import Union | |||
from typing import Any, Dict, List, Union |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From readme I see transformers supports py 3.9+. According to py doc, there is no need to use typing.Dict and List.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Will replace 🤗
What does this PR do?
With the power of
@overload
this PR adds several features to make our pipelines more IDE-friendly (and as a bonus more Curosor, Copilot and autocompletion friendly).1. Correctly resolve pipeline
type
in casetask
is specified for pipeline functionAs a result, we have pipeline-specific docs and method signatures fetched by IDE
2. Resolve ambiguities regarding the input and output types for pipelines
For example,
The part of the code is autogenerated and added to the
pipelines/__init__.py
+ added CI check / fix