Make xsdata optional and add requests-only fallback in FiscalClient#21
Merged
Make xsdata optional and add requests-only fallback in FiscalClient#21
Conversation
d44a378 to
833255b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
xsdataa soft (optional) dependency so basic users need onlyrequests+requests-pkcs12.FiscalClientto perform basic SOAP requests using plain XML whenxsdatais not installed, increasing adoption for lightweight use-cases.xsdata(nfelib / Odoo integrations) by keeping parsing/databinding unchanged when available.Description
xsdatafrom mandatory dependencies and expose it as an optional extraxsdatainpyproject.toml, and document the optional extra and a requests-only usage example inREADME.md.importlib.util.find_spec) and conditional imports so the module can operate with or withoutxsdata, providing lightweight fallback classes and exceptions when missing.FiscalClientthat usesrequests.Sessionwhenxsdatais unavailable, including helpers_session,_post,prepare_headers, and_webservice_name, and a_xsdata_availableflag to route behavior.prepare_payload/sendto accept raw XML payloads (str/bytesor{'raw_xml': ...}) in no-xsdata mode and to return the raw SOAP XML response when parsing is not available; update tests to cover the fallback behavior.Testing
ruff check brazil_fiscal_client testsand the code style/lint checks passed.python -m compileall brazil_fiscal_client testsand compilation succeeded.pytest -qin this environment but test collection failed because the optional test dependencynfelibis not installed here (this is unrelated to the change and affects collection of xsdata-dependent tests).tests/test_fiscal_client.py, and a small automated smoke check invokingFiscalClientin requests-only mode completed successfully in this environment.Codex Task