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

Use PyYAML instead of ruamel.yaml #833

Closed
sevdog opened this issue Jan 27, 2023 · 5 comments
Closed

Use PyYAML instead of ruamel.yaml #833

sevdog opened this issue Jan 27, 2023 · 5 comments
Labels
1.21.x Release target in 1.21.x

Comments

@sevdog
Copy link

sevdog commented Jan 27, 2023

Description

PyYAML is the default YAML serializer used in Django and also the suggested DRF YAML renderer uses it.

If someone uses these library with drf-yasg he is going to have two different YAML parsers, which is quite useless.

Also the concurrent library drf-spectacular uses pyyaml.

Proposal

If there is no particular reason in using ruamel.yaml (whcih as of now means "to support YAML 1.2") it will be better to replace it with pyyaml (for uniformity) or move it as an optional dependency (since YAML relies on a third party library which is not mandatory to generate a schema).

@StevenMapes
Copy link

StevenMapes commented Feb 7, 2023

I'd also recommend moving away from ruamel-yaml ASAP as it requires ruamel-yaml-clib which does not support Python 3.11 and this stops this project working with Python 3.11. The project does work in Python 3.10 as I've been running it on that for a while including Django 3.2, 4.0 and 4.1 :)

@onegreyonewhite
Copy link
Contributor

I'd also recommend moving away from ruamel-yaml ASAP as it requires ruamel-yaml-clib which does not support Python 3.11 and this stops this project working with Python 3.11. The project does work in Python 3.10 as I've been running it on that for a while including Django 3.2, 4.0 and 4.1 :)

Very strange because I just generated a schema in Python 3.11 without problems.
And ruamel-yaml-clib has wheels for Python 3.11.

@StevenMapes
Copy link

StevenMapes commented Feb 8, 2023

I'd also recommend moving away from ruamel-yaml ASAP as it requires ruamel-yaml-clib which does not support Python 3.11 and this stops this project working with Python 3.11. The project does work in Python 3.10 as I've been running it on that for a while including Django 3.2, 4.0 and 4.1 :)

Very strange because I just generated a schema in Python 3.11 without problems. And ruamel-yaml-clib has wheels for Python 3.11.

Interesting. I'll have to try again if it works then great.

update I found my issue. my requirements file was last generated by piptools running on Python 3.10 which makes the 3.11 venv I then tested with fail as it includes the requirement to install ruamel-yaml-clib==0.2.6 via ruamel-yaml whereas when you run it on Python 3.11 it no longer requires that. I'll update my test pipelines for that

@JoelLefkowitz JoelLefkowitz added the 1.21.x Release target in 1.21.x label Feb 8, 2023
@JoelLefkowitz
Copy link
Collaborator

@sevdog thanks for raising this. I agree that PyYAML is the way to go. This repo's release 1.21.5 introduced support for python 3.10 and in release 1.21.6 I would like to add support for python 3.11.

It's worth pointing out that there is an open PR #806 that advances the ruamel.yaml interfaces to use their version 0.17 methods, however in the long term it is in our interest to be consistent with the rest of the Django tooling and make the switch to PyYAML. I'll have a look at updating the codecs and fields.

@tfranzel
Copy link
Contributor

I don't remember the reason why we moved away from ruamel.yaml to pyyaml, but there was definitely one. pyaml works excellently with a couple of light touches.

FYI these were the representer changes we had to make to have a consistent and clean schema:
https://github.com/tfranzel/drf-spectacular/blob/4d50c46c7b6a228c36cbbfe6add0b371f717ce8f/drf_spectacular/renderers.py#L15

onegreyonewhite added a commit to onegreyonewhite/drf-yasg that referenced this issue Mar 18, 2023
JoelLefkowitz pushed a commit that referenced this issue May 16, 2023
* Feature: Migrate to PyYAML for yaml generator.

Closes #833

* Chore: Update swagger ui and redoc dependencies.
JoelLefkowitz pushed a commit that referenced this issue Jun 15, 2023
* Feature: Migrate to PyYAML for yaml generator.

Closes #833

* Chore: Update swagger ui and redoc dependencies.

* Fix: Remove required coreapi dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.21.x Release target in 1.21.x
Projects
None yet
Development

No branches or pull requests

5 participants