refactor(did): requests optional machen (urllib-Fallback)#35
Merged
Conversation
'requests' ist nicht mehr Pflicht-Abhängigkeit (raus aus REQUIRES). Neuer Helper sdata/did/_http.py nutzt requests, falls installiert, sonst urllib aus der Standardbibliothek. TLS-Zertifikatsprüfung bleibt in beiden Fällen aktiv. - _http.http_get(url, headers, timeout) -> (status, text); Transportfehler als backend-neutrale HttpError. did_web/did_github nutzen den Helper statt direkt requests. - deprecated/data.py: top-level 'import requests' entfernt (blockierte sonst 'import sdata' ohne requests); from_url nutzt lazy requests-Import mit urllib-Fallback. - setup.py: 'requests' aus REQUIRES; neues optionales Extra [http]=['requests']; tests_require ergänzt. local-ci.sh bleibt bewusst ohne [http] (validiert den urllib-Pfad; requests-Backend via injiziertem Fake in test_http_backend.py). - Tests auf den Helper umgestellt (mock http_get statt requests.get). Verifiziert ohne requests im Environment: 'import sdata' + did funktionieren (urllib-Fallback), 382 passed, 5 skipped, Coverage 100% (inkl. _http.py).
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 7 minor |
| Security | 2 medium 3 high |
🟢 Metrics 22 complexity · 0 duplication
Metric Results Complexity 22 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Macht
requestszur optionalen Abhängigkeit. Ohnerequestsnutztsdataeinenurllib-Fallback (Standardbibliothek) —sdata.did(undimport sdata) bleiben voll funktionsfähig.Änderungen
sdata/did/_http.py:http_get(url, headers, timeout) → (status, text); bevorzugtrequests, sonsturllib.request. TLS-Verifikation bleibt aktiv in beiden Backends. Transportfehler → backend-neutraleHttpError.did_web.py/did_github.py: nutzen den Helper statt direktrequests.deprecated/data.py: top-levelimport requestsentfernt (blockierte sonstimport sdataohne requests);from_urlmit lazy requests + urllib-Fallback.setup.py:requestsraus ausREQUIRES; neues Extra[http] = ['requests'];tests_requireergänzt.ci/local-ci.sh: bewusst ohne[http]→ validiert den urllib-Default; das requests-Backend ist über ein injiziertes Fake-Modul intests/test_http_backend.pyabgedeckt.http_getstattrequests.get).Installationsmodell
Verifikation
Mit deinstalliertem
requests(und ohneecdsa/base58):import sdata+did:key/did:web-Pfade laufen über urllib.382 passed, 5 skipped, Coverage 100 % (inkl._http.py, beide Backends).