Skip to content

add argument to service for customizing json encoder#59

Merged
behrmann merged 2 commits intovarlink:masterfrom
phlogistonjohn:jjm-srv-json-encoder
May 31, 2025
Merged

add argument to service for customizing json encoder#59
behrmann merged 2 commits intovarlink:masterfrom
phlogistonjohn:jjm-srv-json-encoder

Conversation

@phlogistonjohn
Copy link
Copy Markdown
Contributor

Fixes: #58

This is my first contribution here so let me know if I missed any process items that I missed.

Add a new argument to the Service class so that code using that class
can specify a custom json encoder class, ideally one that subclasses
from VarlinkEncoder.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
@phlogistonjohn phlogistonjohn force-pushed the jjm-srv-json-encoder branch from 62d88d7 to 71473bc Compare May 21, 2025 11:58
@phlogistonjohn
Copy link
Copy Markdown
Contributor Author

Updated to fix ruff check error.

I'd prefer to have tox run the ruff commands so I may follow up this PR with a new PR that moves the ruff rules into the tox.ini and invoke those from tox instead of from the github workflow directly. That way it's harder to miss when checking things locally. :-)

@behrmann
Copy link
Copy Markdown
Collaborator

I'd prefer to have tox run the ruff commands so I may follow up this PR with a new PR that moves the ruff rules into the tox.ini and invoke those from tox instead of from the github workflow directly. That way it's harder to miss when checking things locally. :-)

Happy to take that, but not as tox.ini, but in pyproject.toml instead.

Copy link
Copy Markdown
Collaborator

@behrmann behrmann left a comment

Choose a reason for hiding this comment

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

Thanks! I think this is a nice start. I think similar decoding support would also make sense to add, but having a pluggable encoder is, I think, a good start.

Add a new test file to verify that the json_encoder_cls argument
can be given to the Service to specify a custom encoder.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
@phlogistonjohn phlogistonjohn force-pushed the jjm-srv-json-encoder branch from 71473bc to 82ada90 Compare May 21, 2025 14:23
@phlogistonjohn
Copy link
Copy Markdown
Contributor Author

phlogistonjohn commented May 21, 2025

Happy to take that, but not as tox.ini, but in pyproject.toml instead.

OK. I haven't done the research yet, but if tox can't use both at the same time in one project would you like to see the tox.ini file removed?

@behrmann
Copy link
Copy Markdown
Collaborator

Yes, the tox.ini should be moved into pyproject.toml as a [tool.tox] section.

@behrmann behrmann merged commit 5e515ff into varlink:master May 31, 2025
8 checks passed
@behrmann
Copy link
Copy Markdown
Collaborator

Sorry for the slow turnaround, @phlogistonjohn, I simply forgot pressing merge.

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.

Support customizing server JSON encoding

2 participants