Skip to content

refactor(did): requests optional machen (urllib-Fallback)#35

Merged
lepy merged 1 commit into
masterfrom
refactor/requests-optional
Jun 25, 2026
Merged

refactor(did): requests optional machen (urllib-Fallback)#35
lepy merged 1 commit into
masterfrom
refactor/requests-optional

Conversation

@lepy

@lepy lepy commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Macht requests zur optionalen Abhängigkeit. Ohne requests nutzt sdata einen urllib-Fallback (Standardbibliothek) — sdata.did (und import sdata) bleiben voll funktionsfähig.

Änderungen

  • Neu sdata/did/_http.py: http_get(url, headers, timeout) → (status, text); bevorzugt requests, sonst urllib.request. TLS-Verifikation bleibt aktiv in beiden Backends. Transportfehler → backend-neutrale HttpError.
  • did_web.py / did_github.py: nutzen den Helper statt direkt requests.
  • deprecated/data.py: top-level import requests entfernt (blockierte sonst import sdata ohne requests); from_url mit lazy requests + urllib-Fallback.
  • setup.py: requests raus aus REQUIRES; neues Extra [http] = ['requests']; tests_require ergänzt.
  • ci/local-ci.sh: bewusst ohne [http] → validiert den urllib-Default; das requests-Backend ist über ein injiziertes Fake-Modul in tests/test_http_backend.py abgedeckt.
  • did-Tests auf den Helper umgestellt (mock http_get statt requests.get).

Installationsmodell

pip install sdata          # voll funktionsfähig (urllib-HTTP-Backend)
pip install sdata[http]    # optional: requests als HTTP-Backend

Verifikation

Mit deinstalliertem requests (und ohne ecdsa/base58): import sdata + did:key/did:web-Pfade laufen über urllib. 382 passed, 5 skipped, Coverage 100 % (inkl. _http.py, beide Backends).

'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).
@lepy lepy merged commit e6e7cf3 into master Jun 25, 2026
1 of 2 checks passed
@lepy lepy deleted the refactor/requests-optional branch June 25, 2026 15:25
@codacy-production

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 3 high · 2 medium · 7 minor

Alerts:
⚠ 12 issues (≤ 0 issues of at least minor severity)

Results:
12 new issues

Category Results
Documentation 7 minor
Security 2 medium
3 high

View in Codacy

🟢 Metrics 22 complexity · 0 duplication

Metric Results
Complexity 22
Duplication 0

View in Codacy

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.

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.

1 participant