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

Wrong use of Optional[] in typing for config parameter in the Language class #9012

Closed
MichalMalyska opened this issue Aug 20, 2021 · 2 comments · Fixed by #9024
Closed

Wrong use of Optional[] in typing for config parameter in the Language class #9012

MichalMalyska opened this issue Aug 20, 2021 · 2 comments · Fixed by #9024
Labels
bug Bugs and behaviour differing from documentation feat / pipeline Feature: Processing pipeline and components types Issues related to typing or typing tools

Comments

@MichalMalyska
Copy link

By the definition: https://docs.python.org/3/library/typing.html#typing.Optional
it is meant to signify a Union[sth, None] however if you pass a config=None to the add_pipe method:

config: Optional[Dict[str, Any]] = SimpleFrozenDict(),

you will get an error downstream from here:
if not isinstance(config, dict):

Which page or section is this issue related to?

Code documentation in Language Pipeline
https://github.com/explosion/spaCy/blob/d94ddd568691cfa9d56b353173237afe1f328b43/spacy/language.py

@svlandeg svlandeg added bug Bugs and behaviour differing from documentation types Issues related to typing or typing tools labels Aug 23, 2021
@svlandeg
Copy link
Member

You're right, the code does not allow this parameter to be Optional. Its optional in the sense that there's a default value, but the typing is wrong, we'll get that fixed. Thanks for the report!

@svlandeg svlandeg added the feat / pipeline Feature: Processing pipeline and components label Aug 23, 2021
@github-actions
Copy link
Contributor

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs and behaviour differing from documentation feat / pipeline Feature: Processing pipeline and components types Issues related to typing or typing tools
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants