Add a versioned User-Agent
Why
Library-created Sessions currently use Requests' default User-Agent.
A versioned User-Agent makes requests easier to identify during debugging and gives upstream operators better information if the package causes unexpected traffic.
Parent release issue: #265
Required behavior
Library-created Sessions should send a User-Agent similar to:
python-mlb-statsapi/0.9.0
The package version must come from package metadata rather than a separately maintained hardcoded constant.
Session ownership requirements
For a library-created Session:
- Set the package User-Agent
- Preserve other default Session headers
- Use the installed package version
For a caller-injected Session:
- Do not overwrite the caller's User-Agent
- Do not modify other caller-defined headers
- Leave all header configuration under caller control
Applications using an injected Session may continue supplying their own value:
session.headers.update({
"User-Agent": "my-baseball-project/1.0",
})
Testing requirements
- Library-created Sessions include the package name
- Library-created Sessions include the installed package version
- Package metadata is the version source
- Injected Session User-Agent values are preserved
- Other injected Session headers are preserved
- No network access is required for tests
Suggested branch
feat/versioned-user-agent
The branch should start from and target:
Acceptance criteria
- Library-created requests identify the package and version
- Injected Session headers remain untouched
- The version is not duplicated in multiple source files
- Existing Session and retry behavior remains unchanged
- Offline tests pass
Not included
- Machine identifiers
- User tracking
- Telemetry
- Automatic application-name discovery
- Changes to injected Session headers
Add a versioned User-Agent
Why
Library-created Sessions currently use Requests' default User-Agent.
A versioned User-Agent makes requests easier to identify during debugging and gives upstream operators better information if the package causes unexpected traffic.
Parent release issue: #265
Required behavior
Library-created Sessions should send a User-Agent similar to:
The package version must come from package metadata rather than a separately maintained hardcoded constant.
Session ownership requirements
For a library-created Session:
For a caller-injected Session:
Applications using an injected Session may continue supplying their own value:
Testing requirements
Suggested branch
The branch should start from and target:
Acceptance criteria
Not included