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

Upgrade PyYAML to version 6 #6183

Merged
merged 8 commits into from
Oct 22, 2021
Merged

Upgrade PyYAML to version 6 #6183

merged 8 commits into from
Oct 22, 2021

Conversation

srittau
Copy link
Collaborator

@srittau srittau commented Oct 18, 2021

No description provided.

* Replace Text with str
* Replace alias "_Str" with str
* Import from collections.abc and re where applicable
* Remove Python 2 branches
@@ -1,2 +1 @@
version = "5.4.*"
python2 = true
version = "6.0"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really want to specify an exact version? pip install 6.0.0 works, and looking at the changelog, bugfix releases will likely be numbered like 6.0.x.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Using 6.0.* won't work, because there is no matching version at the moment. We can update this, once 6.0.1 gets released.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The following seems to work just fine for me, pip install 'pyyaml==6.0.*'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's weird. There were problems with using stars for non-existing parts in CI when doing the change to allowing star syntax. I'll try it here.

@Akuli
Copy link
Collaborator

Akuli commented Oct 19, 2021

This introduces a bunch of new stubtest warnings, but they somehow don't occur in CI. Here's this PR, with pyyaml 6.0 (aka pyyaml 6.0.0, both seem to install the same thing):

(env) akuli@akuli-desktop:~/typeshed$ MYPYPATH=stubs/PyYAML/ python3 -m mypy.stubtest --concise yaml
yaml.CBaseDumper.__init__ is inconsistent, stub does not have argument "sort_keys"
yaml.CDumper.__init__ is inconsistent, stub argument "canonical" differs from runtime argument "default_style"
yaml.CDumper.__init__ is inconsistent, stub argument "indent" differs from runtime argument "default_flow_style"
yaml.CDumper.__init__ is inconsistent, stub argument "width" differs from runtime argument "canonical"
yaml.CDumper.__init__ is inconsistent, stub argument "allow_unicode" differs from runtime argument "indent"
yaml.CDumper.__init__ is inconsistent, stub argument "line_break" differs from runtime argument "width"
yaml.CDumper.__init__ is inconsistent, stub argument "encoding" differs from runtime argument "allow_unicode"
yaml.CDumper.__init__ is inconsistent, stub argument "explicit_start" differs from runtime argument "line_break"
yaml.CDumper.__init__ is inconsistent, stub argument "explicit_end" differs from runtime argument "encoding"
yaml.CDumper.__init__ is inconsistent, stub argument "version" differs from runtime argument "explicit_start"
yaml.CDumper.__init__ is inconsistent, stub argument "tags" differs from runtime argument "explicit_end"
yaml.CDumper.__init__ is inconsistent, stub does not have argument "version"
yaml.CDumper.__init__ is inconsistent, stub does not have argument "tags"
yaml.CDumper.__init__ is inconsistent, stub does not have argument "sort_keys"
yaml.CEmitter is not present at runtime
yaml.CParser is not present at runtime
yaml.YAMLObjectMetaclass.__init__ is inconsistent, stub argument "self" differs from runtime argument "cls"
yaml.warnings is not present in stub
yaml.constructor.BaseConstructor.check_state_key is not present in stub
yaml.constructor.FullConstructor.get_state_keys_blacklist is not present in stub
yaml.constructor.FullConstructor.get_state_keys_blacklist_regexp is not present in stub
yaml.constructor.FullConstructor.set_python_instance_state is inconsistent, stub does not have argument "unsafe"
yaml.cyaml.CBaseDumper.__init__ is inconsistent, stub does not have argument "sort_keys"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "canonical" differs from runtime argument "default_style"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "indent" differs from runtime argument "default_flow_style"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "width" differs from runtime argument "canonical"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "allow_unicode" differs from runtime argument "indent"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "line_break" differs from runtime argument "width"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "encoding" differs from runtime argument "allow_unicode"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "explicit_start" differs from runtime argument "line_break"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "explicit_end" differs from runtime argument "encoding"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "version" differs from runtime argument "explicit_start"
yaml.cyaml.CDumper.__init__ is inconsistent, stub argument "tags" differs from runtime argument "explicit_end"
yaml.cyaml.CDumper.__init__ is inconsistent, stub does not have argument "version"
yaml.cyaml.CDumper.__init__ is inconsistent, stub does not have argument "tags"
yaml.cyaml.CDumper.__init__ is inconsistent, stub does not have argument "sort_keys"
yaml.cyaml.CEmitter.close is not present in stub
yaml.cyaml.CEmitter.dispose is not present in stub
yaml.cyaml.CEmitter.emit is not present in stub
yaml.cyaml.CEmitter.open is not present in stub
yaml.cyaml.CEmitter.serialize is not present in stub
yaml.cyaml.CParser.raw_parse is not present in stub
yaml.cyaml.CParser.raw_scan is not present in stub

master with pyyaml 5.4.1:

yaml.CBaseDumper is not present at runtime
yaml.CBaseLoader is not present at runtime
yaml.CDumper is not present at runtime
yaml.CEmitter is not present at runtime
yaml.CFullLoader is not present at runtime
yaml.CLoader is not present at runtime
yaml.CParser is not present at runtime
yaml.CSafeLoader is not present at runtime
yaml.CUnsafeLoader is not present at runtime
yaml.YAMLLoadWarning is not present in stub
yaml.YAMLObjectMetaclass.__init__ is inconsistent, stub argument "self" differs from runtime argument "cls"
yaml.load_warning is not present in stub
yaml.warnings is not present in stub
yaml.constructor.BaseConstructor.check_state_key is not present in stub
yaml.constructor.FullConstructor.get_state_keys_blacklist is not present in stub
yaml.constructor.FullConstructor.get_state_keys_blacklist_regexp is not present in stub
yaml.constructor.FullConstructor.set_python_instance_state is inconsistent, stub does not have argument "unsafe"
yaml.cyaml failed to import: No module named 'yaml._yaml'

@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Oct 19, 2021

It's because they're allowlisted: https://github.com/python/typeshed/blob/master/stubs/PyYAML/@tests/stubtest_allowlist.txt
(+ that we run in CI with --ignore-missing-stub)

allowlist dates back to the initial commit, which means they're allowlisted to have CI be green, rather than any especially good reason.

@srittau
Copy link
Collaborator Author

srittau commented Oct 19, 2021

I'll have a look.

* Add yaml._yaml and move CParser and CEmitter there.
* Add missing functions, classes, and arguments.
* Use relative imports in some modules.
* Add __all__ to yaml.cyaml.
* Remove unnecessary noqa markers.
* Update arguments.
Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Thanks, skimmed, seems fine!

@srittau srittau merged commit 4e592ad into python:master Oct 22, 2021
@srittau srittau deleted the pyyaml-6 branch October 22, 2021 18:06
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