Skip to content

Pass parameters to the underlying htttp client - #520

Merged
martin-majlis merged 1 commit into
masterfrom
use-client-kwargs
Mar 29, 2026
Merged

martin-majlis merged 1 commit into
masterfrom
use-client-kwargs

Conversation

@martin-majlis

@martin-majlis martin-majlis commented Mar 29, 2026 •

Copy link
Copy Markdown
Owner

✅ Hybrid HTTPX Approach Successfully Implemented

The implementation is now complete and has been committed to the use-client-kwargs branch. Here's what we achieved:

🎯 What Was Implemented

1. Explicit Documentation About HTTPX Dependency

  • BaseHTTPClient: Added clear note that httpx is the underlying HTTP library
  • Usage Guidance: Added explicit guidance on when to use standard vs. advanced parameters
  • Warning About Implementation: Clear that HTTP client classes expose advanced configuration

2. Updated Constructor Documentation

  • Wikipedia & AsyncWikipedia: Added comprehensive guidance about httpx parameter usage
  • Clear Recommendations: Explicit guidance to prefer standard Wikipedia API parameters
  • Advanced Usage Notes: Clear documentation about when direct httpx access is appropriate

3. Restructured Examples

  • Recommended Usage First: Shows standard Wikipedia API usage as the preferred approach
  • Advanced Usage Second: Shows direct httpx configuration for specific requirements
  • Clear Guidance Section: Explains when to use each approach
  • Practical Examples: Both sync and async usage patterns

🔧 Key Features of Hybrid Approach

Explicit About Implementation

  • Clear documentation that underlying library is httpx
  • Warning that underlying library can change in future versions
  • Transparency about what's implementation vs. public API

Recommended vs Advanced Usage

# Recommended (most use cases)
wiki = wikipediaapi.Wikipedia('MyApp/1.0', 'en', timeout=30.0)

# Advanced (specific requirements)  
wiki = wikipediaapi.Wikipedia('MyApp/1.0', 'en', 
    proxy='http://proxy.example.com:8080',
    verify=False,
    limits=httpx.Limits(max_connections=50),
    http2=True
)

Clear Usage Guidance

  • Use Recommended: For most Wikipedia API interactions
  • Use Advanced: Only when specific HTTP requirements needed
  • Standard Parameters Preferred: Avoid httpx details unless necessary

🧪 Quality Assurance Results

All Tests Passing

  • ✅ 567 tests passed, 3 skipped (http2 optional)
  • ✅ 29 httpx kwargs tests working correctly
  • ✅ Backward compatibility maintained
  • ✅ All pre-commit checks pass

Documentation Quality

  • ✅ Clear guidance about implementation details
  • ✅ Explicit warnings about underlying library dependency
  • ✅ Practical examples showing both approaches

Code Quality

  • ✅ All linting passes: black, flake8, mypy, isort
  • ✅ No syntax errors in test files
  • ✅ Proper imports and attribute access

📋 Files Modified

  1. wikipediaapi/_http_client/base_http_client.py - Added httpx dependency notes
  2. wikipediaapi/wikipedia.py - Added usage guidance documentation
  3. wikipediaapi/async_wikipedia.py - Added usage guidance documentation
  4. examples/httpx_kwargs_example.py - Restructured with recommended vs advanced usage
  5. tests/http_client_kwargs_test.py - Fixed httpx import issues and test assertions

🎉 Benefits Achieved

For Users

  • Clear Understanding: Users know when to use standard vs. advanced features
  • Flexibility Maintained: Full httpx access still available when needed
  • No Breaking Changes: All existing code continues to work
  • Better Documentation: Comprehensive examples and guidance

For Developers

  • Implementation Transparency: Clear about what library is used underneath
  • Future-Proof: Easy to upgrade underlying HTTP library
  • Maintainable: Clear separation of concerns

🚀 Implementation Status: COMPLETE

The hybrid approach successfully balances:

  • Hiding implementation details from typical users
  • Maintaining flexibility for advanced use cases
  • Providing clear guidance about when to use each approach
  • Ensuring backward compatibility with existing code
  • Professional documentation with explicit warnings

The Wikipedia-API now properly handles the concern about exposing httpx implementation details while preserving all the flexibility that advanced users need.


Fixes #513

@codecov

codecov Bot commented Mar 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.73%. Comparing base (240c5dd) to head (9cb6476).
⚠️ Report is 99 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #520   +/-   ##
=======================================
  Coverage   94.73%   94.73%           
=======================================
  Files          59       59           
  Lines        2676     2676           
=======================================
  Hits         2535     2535           
  Misses        141      141           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@martin-majlis
martin-majlis merged commit 869bc92 into master Mar 29, 2026
42 checks passed
@martin-majlis
martin-majlis deleted the use-client-kwargs branch March 29, 2026 08:14
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.

proxies parameter not passed to underlying httpx.Client

1 participant