-
Notifications
You must be signed in to change notification settings - Fork 218
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
refactor: cobra.io.yaml #1152
refactor: cobra.io.yaml #1152
Conversation
src/cobra/io/yaml.py
Outdated
class CobraYAML(YAML): | ||
"""Define custom subclass for YAML I/O.""" | ||
|
||
def dump(self, data: Dict, stream: Optional[Any] = None, **kwargs: Any) -> str: |
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.
I think the type of stream
can be https://docs.python.org/3/library/io.html#io.TextIOBase rather than Any
.
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.
What about we use something more specific: https://docs.python.org/3/library/io.html#io.StringIO ?
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.
My thinking was that if someone passes a stream, it will not be StringIO
but some other text stream. So it's a bit more broad to go with TextIOBase
.
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.
Okay sounds fair. I'll change it.
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.
Thank you 🙂
This PR adds typing annotations for cobra.io.yaml and its unit tests. It also upgrades the code style for them to maintain Python 3.6+ compatibility.