speedtest-ng 3.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. speedtest_ng-3.0.0/.github/workflows/ci.yml +52 -0
  2. speedtest_ng-3.0.0/.github/workflows/live_api.yml +30 -0
  3. speedtest_ng-3.0.0/.github/workflows/publish.yml +32 -0
  4. speedtest_ng-3.0.0/.gitignore +39 -0
  5. speedtest_ng-3.0.0/AGENTS.md +135 -0
  6. speedtest_ng-3.0.0/CHANGELOG.md +31 -0
  7. speedtest_ng-3.0.0/CONTRIBUTING.md +39 -0
  8. speedtest_ng-3.0.0/LICENSE +202 -0
  9. speedtest_ng-3.0.0/PKG-INFO +130 -0
  10. speedtest_ng-3.0.0/PLAN.md +89 -0
  11. speedtest_ng-3.0.0/README.md +104 -0
  12. speedtest_ng-3.0.0/pyproject.toml +107 -0
  13. speedtest_ng-3.0.0/speedtest/__init__.py +70 -0
  14. speedtest_ng-3.0.0/speedtest/__main__.py +8 -0
  15. speedtest_ng-3.0.0/speedtest/async_client.py +387 -0
  16. speedtest_ng-3.0.0/speedtest/cli.py +391 -0
  17. speedtest_ng-3.0.0/speedtest/client.py +188 -0
  18. speedtest_ng-3.0.0/speedtest/exceptions.py +76 -0
  19. speedtest_ng-3.0.0/speedtest/metrics.py +113 -0
  20. speedtest_ng-3.0.0/speedtest/models.py +209 -0
  21. speedtest_ng-3.0.0/speedtest/py.typed +0 -0
  22. speedtest_ng-3.0.0/speedtest/transport/__init__.py +35 -0
  23. speedtest_ng-3.0.0/speedtest/transport/http.py +784 -0
  24. speedtest_ng-3.0.0/speedtest/transport/tcp.py +491 -0
  25. speedtest_ng-3.0.0/speedtest-cli.1 +143 -0
  26. speedtest_ng-3.0.0/tests/__init__.py +1 -0
  27. speedtest_ng-3.0.0/tests/conftest.py +272 -0
  28. speedtest_ng-3.0.0/tests/test_async_client.py +318 -0
  29. speedtest_ng-3.0.0/tests/test_cli.py +281 -0
  30. speedtest_ng-3.0.0/tests/test_client.py +165 -0
  31. speedtest_ng-3.0.0/tests/test_ha_compat.py +221 -0
  32. speedtest_ng-3.0.0/tests/test_http_transport.py +499 -0
  33. speedtest_ng-3.0.0/tests/test_real_api_calls.py +48 -0
  34. speedtest_ng-3.0.0/tests/test_tcp_transport.py +216 -0
  35. speedtest_ng-3.0.0/uv.lock +1284 -0
@@ -0,0 +1,52 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ workflow_dispatch:
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ jobs:
14
+ test:
15
+ name: Python ${{ matrix.python-version }}
16
+ runs-on: ubuntu-latest
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ python-version:
21
+ - "3.11"
22
+ - "3.12"
23
+ - "3.13"
24
+ - "3.14"
25
+
26
+ steps:
27
+ - name: Checkout repository
28
+ uses: actions/checkout@v7
29
+
30
+ - name: Set up uv and Python ${{ matrix.python-version }}
31
+ uses: astral-sh/setup-uv@v10.4.0
32
+ with:
33
+ enable-cache: true
34
+ python-version: ${{ matrix.python-version }}
35
+
36
+ - name: Install dependencies
37
+ run: uv sync --locked --all-groups
38
+
39
+ - name: Lint with Ruff
40
+ run: uv run ruff check --no-fix .
41
+
42
+ - name: Check formatting with Ruff
43
+ run: uv run ruff format --check .
44
+
45
+ - name: Typecheck with Mypy
46
+ run: uv run mypy speedtest tests
47
+
48
+ - name: Run offline test suite with branch coverage
49
+ run: uv run pytest
50
+
51
+ - name: Build wheel and sdist
52
+ run: uv build
@@ -0,0 +1,30 @@
1
+ name: Live API Tests
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ schedule:
6
+ - cron: "0 10 * * 1"
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ live-api:
13
+ name: Live Speedtest.net Integration
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout repository
18
+ uses: actions/checkout@v7
19
+
20
+ - name: Set up uv
21
+ uses: astral-sh/setup-uv@v10.4.0
22
+ with:
23
+ enable-cache: true
24
+ python-version: "3.13"
25
+
26
+ - name: Install dependencies
27
+ run: uv sync --locked --all-groups
28
+
29
+ - name: Run live Speedtest.net tests
30
+ run: uv run pytest -m real_api_call --no-cov -v
@@ -0,0 +1,32 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+ id-token: write
12
+
13
+ jobs:
14
+ publish:
15
+ name: Build and publish to PyPI
16
+ runs-on: ubuntu-latest
17
+ environment: pypi
18
+
19
+ steps:
20
+ - name: Checkout repository
21
+ uses: actions/checkout@v7
22
+
23
+ - name: Set up uv
24
+ uses: astral-sh/setup-uv@v10.4.0
25
+
26
+ - name: Build wheel and sdist
27
+ run: uv build
28
+
29
+ - name: Publish distributions to PyPI (OIDC)
30
+ uses: pypa/gh-action-pypi-publish@release/v1
31
+ with:
32
+ attestations: true
@@ -0,0 +1,39 @@
1
+ *.py[co]
2
+
3
+ # Packages
4
+ *.egg
5
+ *.egg-info
6
+ dist
7
+ build
8
+ eggs
9
+ parts
10
+ bin
11
+ var
12
+ sdist
13
+ develop-eggs
14
+ .installed.cfg
15
+
16
+ # Installer logs
17
+ pip-log.txt
18
+
19
+ # Unit test / coverage reports
20
+ .coverage
21
+ .tox
22
+
23
+ #Translations
24
+ *.mo
25
+
26
+ #Mr Developer
27
+ .mr.developer.cfg
28
+
29
+ # Modern Python tooling & local environments
30
+ .venv/
31
+ .mypy_cache/
32
+ .pytest_cache/
33
+ .ruff_cache/
34
+ .env
35
+ __pycache__/
36
+ htmlcov/
37
+ coverage.xml
38
+ *.egg-info/
39
+
@@ -0,0 +1,135 @@
1
+ # AGENTS.md — `speedtest-ng`
2
+
3
+ ## 1. Project Identity & Mission
4
+
5
+ - **Repository:** `marcomsousa/speedtest-ng` (100% independent public mirror, `isFork: false`)
6
+ - **Upstream Origin:** `sivel/speedtest-cli` (Matt Martz) — **officially archived (read-only) on April 30, 2026**; last pushed July 20, 2024; `master` at `2.1.4b1`, last PyPI release `2.1.3`.
7
+ - **License & Attribution:** **Apache License 2.0** (`LICENSE`). Preserve original copyright attribution (`Copyright 2012 Matt Martz`) and full Git history.
8
+ - **Primary Target:** Modern, drop-in, actively maintained Python 3.11+ successor to `speedtest-cli` on PyPI (`speedtest-ng`, exposing `import speedtest`) — engineered to modernize Home Assistant Core's built-in `speedtestdotnet` integration (`requirements = ["speedtest-cli==2.1.3"]`) and dramatically improve throughput accuracy on Gigabit+ fiber connections.
9
+
10
+ ---
11
+
12
+ ## 2. Next-Gen (`ng`) Goals & Resolved Upstream Debt
13
+
14
+ ### Phase A — Packaging, Runtime & Tooling Modernization (Implemented in `3.0.0`)
15
+ 1. **Packaging on `uv` + `hatchling` (PEP 621 / 639 / 735):**
16
+ - `pyproject.toml` + `uv.lock` with `requires-python = ">=3.11"`, `name = "speedtest-ng"`, `speedtest/` package + `py.typed` (PEP 561), and CLI entry points `speedtest = "speedtest.cli:main"` / `speedtest-cli = "speedtest.cli:main"`.
17
+ 2. **Legacy Shims & Deprecations Removed:**
18
+ - Removed ~500 lines of Python 2.4–3.10 shims (`urllib2`, `httplib`, `Queue`, `urlparse`, `cgi`, `optparse`, `cStringIO`, `__builtin__`, `_Py3Utf8Output`, `FakeShutdownEvent.isSet` retained as thin alias only, `minidom` fallback `NameError`, `get_exception()`, `PY25PLUS`–`PY310PLUS`, `timeit.time.sleep()`).
19
+ - Replaced `datetime.utcnow()` with `datetime.now(UTC)` and `global DEBUG` / `print_()` with standard `logging.getLogger("speedtest")` (enabling `"loggers": ["speedtest"]` in HA Core).
20
+ 3. **Strict Static Typing, Linting & Formatting:**
21
+ - `ruff` (`line-length = 88`, rules: `ASYNC`, `B`, `C4`, `E`, `F`, `I`, `PT`, `PTH`, `RUF`, `SIM`, `TC`, `UP`, `W` — note `TC`, not deprecated `TCH`) and `mypy --strict` (`warn_unreachable = true`) across `speedtest/` and `tests/`.
22
+
23
+ ### Phase B — Engine, Protocol & Accuracy Improvements (Implemented in `3.0.0`)
24
+ 1. **Native `asyncio` Engine (`AsyncSpeedtest`) + Injectable `aiohttp.ClientSession`:**
25
+ - Replaces blocking `urllib` + `threading` + 10 KiB reads + `sleep(0.001)` busy-wait loops with native `asyncio`, 256 KiB `memoryview` shared buffers (eliminating per-request upload allocations linked to HA `#191133`), and keep-alive `aiohttp.ClientSession` (injectable by HA Core without closing external sessions).
26
+ - Drop-in synchronous `Speedtest` facade executes safely across arbitrary `hass.async_add_executor_job` worker threads and inside active event loops, closing internal sessions cleanly before loop exit.
27
+ 2. **Clean-Room `OoklaServer` Raw TCP Protocol (`:8080`) with Transparent HTTP Fallback:**
28
+ - Pure-Python `asyncio` implementation (`HI` -> `HELLO`, `PING` -> `PONG`, `DOWNLOAD`, `UPLOAD` with header-inclusive payload length, `QUIT`) informed by open-source clean-room references (`origin/socket` prototype + MIT-licensed `showwin/speedtest-go`).
29
+ - Automatically falls back to async `aiohttp` whenever port `8080` is unreachable/firewalled.
30
+ - **Never reverse-engineer Ookla's proprietary CLI binary** (violates Ookla EULA).
31
+ 3. **Measurement & Bug Fixes Mapped to Open HA Core Issues:**
32
+ - **HA `#174958` (`1,800,000 ms` ping):** Discards failed probes instead of appending `3600` and dividing by `6`, preserves `.i` latency cache-busters, honors timeouts/proxies, breaks ties cleanly, and raises `SpeedtestBestServerFailure` when all probes fail.
33
+ - **HA `#179173`, `#115775`, `#135862` (distant/disappearing servers):** Uses `/api/js/servers` JSON discovery first with XML fallback/supplement, never mutates caller `servers`/`exclude` lists, raises `ServersRetrievalError` when all endpoints fail, and clears `self.closest` idempotently.
34
+ - **HA `#178446` (multi-gigabit under-reporting):** Dynamic multi-stream scaling + warm-up/trimmed-mean bandwidth estimation (`speedtest/metrics.py`), plus additive non-breaking fields (`jitter`, `loaded_ping_download`, `loaded_ping_upload`, `packet_loss`, `protocol`) in `SpeedtestResults`.
35
+ - **HA `#191133` (OOM / fd leaks):** Shared zero-copy upload payload buffer, no import-time stdout/stderr `FileIO(..., closefd=True)` wrapping, and guaranteed `finally` cleanup.
36
+ - **State & crash fixes:** Refreshes `results.timestamp` and clears `_share` on each run; enforces `secure=True` by default and modernizes `User-Agent` to avoid HTTP 403 rejections.
37
+
38
+ ### Phase C — Testing & CI/CD (Implemented in `3.0.0`)
39
+ 1. **Deterministic Offline Unit & HA Compat Suite (`pytest`):**
40
+ - `filterwarnings = ["error"]`, `--cov=speedtest --cov-branch`, `fail_under = 95`, loopback mock `OoklaServer`, `aioresponses`, and `tests/test_ha_compat.py`.
41
+ 2. **Opt-In Live Integration Tests (`@pytest.mark.real_api_call`):**
42
+ - Excluded from default `uv run pytest`; runnable locally or via weekly `.github/workflows/live_api.yml`.
43
+ 3. **GitHub Actions Workflows:**
44
+ - `.github/workflows/ci.yml`: matrix (`Python 3.11`–`3.14`), `astral-sh/setup-uv@v10.4.0`, `ruff check`, `ruff format --check`, `mypy`, `pytest`, `uv build`.
45
+ - `.github/workflows/publish.yml`: PyPI OIDC Trusted Publishing (`pypa/gh-action-pypi-publish@release/v1`, `environment: pypi`, `attestations: true`) on release or `workflow_dispatch`.
46
+ - `.github/workflows/live_api.yml`: weekly cron + `workflow_dispatch` live verification.
47
+
48
+ ---
49
+
50
+ ## 3. Repository Architecture Map
51
+
52
+ ```text
53
+ speedtest-ng/
54
+ ├── AGENTS.md # Modernization blueprint & HA invariants
55
+ ├── CHANGELOG.md # Release history (3.0.0+)
56
+ ├── CONTRIBUTING.md # Contribution guidelines
57
+ ├── LICENSE # Apache License 2.0
58
+ ├── README.md # Documentation & usage examples
59
+ ├── pyproject.toml # uv + hatchling + ruff + mypy + pytest config
60
+ ├── uv.lock # Locked dependencies
61
+ ├── speedtest-cli.1 # Man page
62
+ ├── speedtest/
63
+ │ ├── __init__.py # Public exports (drop-in compatible with 2.1.3)
64
+ │ ├── __main__.py # `python -m speedtest` entrypoint
65
+ │ ├── py.typed # PEP 561 marker
66
+ │ ├── exceptions.py # SpeedtestException hierarchy
67
+ │ ├── models.py # SpeedtestResults, ServerDict, helpers
68
+ │ ├── metrics.py # Trimmed-mean estimator, jitter, stream scaling
69
+ │ ├── async_client.py # Native asyncio AsyncSpeedtest engine
70
+ │ ├── client.py # Drop-in synchronous Speedtest facade
71
+ │ ├── cli.py # Modern argparse CLI (speedtest / speedtest-cli)
72
+ │ └── transport/
73
+ │ ├── __init__.py
74
+ │ ├── tcp.py # Clean-room OoklaServer port 8080 TCP protocol
75
+ │ └── http.py # Async aiohttp HTTP/HTTPS fallback & discovery
76
+ ├── tests/
77
+ │ ├── conftest.py # Fixtures & loopback mock OoklaServer
78
+ │ ├── test_ha_compat.py # Live HA Core speedtestdotnet contract tests
79
+ │ ├── test_tcp_transport.py # OoklaServer TCP protocol & error tests
80
+ │ ├── test_http_transport.py # HTTP fallback, JSON/XML discovery & error tests
81
+ │ ├── test_async_client.py # AsyncSpeedtest & metrics tests
82
+ │ ├── test_client.py # Sync Speedtest facade & results tests
83
+ │ ├── test_cli.py # CLI flags & exit handling tests
84
+ │ └── test_real_api_calls.py # @pytest.mark.real_api_call live tests
85
+ └── .github/workflows/
86
+ ├── ci.yml # Lint, format, mypy, pytest matrix, build
87
+ ├── live_api.yml # Scheduled & manual live API verification
88
+ └── publish.yml # PyPI OIDC trusted publish
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 4. Domain Invariants (Must Not Break)
94
+
95
+ Verified against live `homeassistant/components/speedtestdotnet` (`__init__.py`, `coordinator.py`, `diagnostics.py`, `sensor.py`, `quality_scale.yaml`, and `tests/components/speedtestdotnet/test_init.py`):
96
+
97
+ 1. **Top-Level Imports:** `import speedtest` must expose `Speedtest`, `SpeedtestException`, `ConfigRetrievalError`, `NoMatchedServers`, `SpeedtestBestServerFailure`, and all existing exception subclasses.
98
+ 2. **HA Core Call Sequence:**
99
+ - `api = speedtest.Speedtest(secure=True)` (runs in executor; raises `ConfigRetrievalError` on setup failure).
100
+ - `api.get_servers()` -> returns `dict[float, list[dict[str, Any]]]` keyed by distance, where each server dict contains `"country"`, `"name"`, `"sponsor"`, `"cc"`, and `"id"`.
101
+ - `api.closest.clear()` -> `api.closest` must remain a mutable `list`.
102
+ - `api.get_servers(servers=[server_id])` -> filters by server ID (accepts `int` or numeric `str`); raises `speedtest.NoMatchedServers` when none match.
103
+ - `best_server = api.get_best_server()` -> returns server dict with `"id"`, `"name"`, `"country"`, `"cc"`, `"sponsor"`, and `"latency"`.
104
+ - `api.download()` and `api.upload()` -> populate `api.results` and return speeds in **bits per second (bps)** as `float`.
105
+ - `api.results.dict()` -> returns `dict[str, Any]` containing `"download"` (bps), `"upload"` (bps), `"ping"` (ms), `"server"` (dict with `"id"`, `"name"`, `"country"`, `"cc"`, `"sponsor"`, `"latency"`), `"timestamp"` (ISO-8601 UTC string), `"bytes_sent"`, `"bytes_received"`, `"share"`, and `"client"` (plus additive metrics).
106
+ 3. **Exception Hierarchy:** All runtime errors inherit from `speedtest.SpeedtestException`.
107
+ 4. **Units:** `download` and `upload` are always **bits per second**; `ping`, `jitter`, and loaded latency are **milliseconds**.
108
+ 5. **CLI Compatibility:** Preserves `--simple`, `--json`, `--csv`, `--csv-delimiter`, `--csv-header`, `--bytes`, `--server`, `--exclude`, `--list`, `--mini`, `--no-download`, `--no-upload`, `--single`, `--secure`, `--no-secure`, `--source`, `--timeout`, `--version`, `--no-pre-allocate`, and `--protocol {auto,tcp,http}`.
109
+ 6. **Platinum Quality Scale Target in HA Core:** `quality_scale.yaml` lists `async-dependency`, `inject-websession`, and `strict-typing` as remaining Platinum blockers — addressed by `AsyncSpeedtest(session=...)` and `py.typed`.
110
+
111
+ ---
112
+
113
+ ## 5. Development, Testing & Release Guidelines
114
+
115
+ - **Git Identity:** Always commit under `Marco Sousa <marcomsousa@gmail.com>` (`marcomsousa` GitHub account). Follow Conventional Commits (`chore:`, `feat:`, `fix:`, `refactor:`, `test:`, `ci:`, `docs:`).
116
+ - **Standard Verification Commands:**
117
+ ```bash
118
+ uv sync --locked --all-groups
119
+ uv run ruff check --no-fix .
120
+ uv run ruff format --check .
121
+ uv run mypy speedtest tests
122
+ uv run pytest
123
+ uv build
124
+ ```
125
+ - **Live Network Tests (opt-in only):**
126
+ ```bash
127
+ uv run pytest -m real_api_call --no-cov
128
+ ```
129
+ - **Publishing to PyPI:**
130
+ - Use **PyPI OIDC Trusted Publishing** (`marcomsousa/speedtest-ng`, workflow `publish.yml`, environment `pypi`). Never commit PyPI tokens.
131
+ - Trigger releases via GitHub Releases (`gh release create vX.Y.Z ...`). Never reuse a deleted PyPI version filename.
132
+ - **Upstream Home Assistant Core PR Strategy (2-PR Rule):**
133
+ - **PR 1:** Minimal dependency swap only (`speedtest-cli==2.1.3` -> `speedtest-ng==X.Y.Z` in `manifest.json` and `requirements_all.txt`) leveraging drop-in compatibility.
134
+ - **PR 2:** Follow-up PR after PR 1 merges to adopt `AsyncSpeedtest`, injectable `aiohttp.ClientSession`, `"loggers": ["speedtest"]`, jitter/bufferbloat sensors, and companion HA cleanup (`coordinator.servers` clearing, `DEFAULT_SERVER` constant in `config_flow.py`, upload assertion in `test_sensor.py`).
135
+ - **Legacy Upstream Branches Note:** The mirror preserves 21 historical upstream branches (`24test`, `devel`, `modularize`, `socket`, etc.) for reference; confirm before pruning non-bot branches from `origin`.
@@ -0,0 +1,31 @@
1
+ # Changelog
2
+
3
+ All notable changes to `speedtest-ng` are documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [3.0.0] - 2026-11-21
9
+
10
+ ### Added
11
+
12
+ - Modular, PEP 561-typed `speedtest` package (`speedtest/py.typed`) exposing both `AsyncSpeedtest` (with optional injected `aiohttp.ClientSession`) and the drop-in synchronous `Speedtest` facade.
13
+ - Clean-room `OoklaServer` raw TCP (`:8080`) transport (`speedtest/transport/tcp.py`) supporting `HI`/`HELLO`, `PING`/`PONG`, `DOWNLOAD`, `UPLOAD` (header-inclusive framing), and `QUIT` with automatic fallback to keep-alive `aiohttp` (`speedtest/transport/http.py`).
14
+ - Dynamic multi-stream scaling, warm-up + trimmed-mean throughput estimation, concurrent loaded-latency (bufferbloat) probing, and additive `SpeedtestResults` fields (`jitter`, `loaded_ping_download`, `loaded_ping_upload`, `packet_loss`, `protocol`).
15
+ - Primary JSON server discovery via `/api/js/servers` with automatic XML fallback and `--protocol {auto,tcp,http}` / `--no-secure` CLI flags.
16
+ - Deterministic offline `pytest` suite (`>= 95%` branch coverage, `filterwarnings = ["error"]`), `tests/test_ha_compat.py`, opt-in `@pytest.mark.real_api_call` live tests, and GitHub Actions CI, OIDC publish, and weekly live API workflows.
17
+
18
+ ### Fixed
19
+
20
+ - **Unreachable servers returning `1,800,000 ms` ping** (Home Assistant `#174958`): failed latency probes are discarded instead of appending `3600`, RTT averages divide by actual probe count instead of `6`, per-probe `.i` cache-busters are preserved, `timeout` and proxy settings are honored, and `SpeedtestBestServerFailure` is raised when no candidate responds.
21
+ - **Memory growth and socket/fd leaks** (Home Assistant `#191133`): replaced per-request `HTTPUploaderData.pre_allocate()` buffers with a single shared read-only `memoryview` slice, removed import-time `_Py3Utf8Output` / `FileIO(..., closefd=True)` stdout/stderr wrapping (`ResourceWarning` on Python 3.14), and closed all sockets/sessions in `finally` blocks.
22
+ - **Stale/distant 10-server XML discovery & disappearing pinned servers** (Home Assistant `#179173`, `#115775`, `#135862`): `/api/js/servers` discovers local servers accurately while XML endpoints serve as fallback/supplement; all-failed discovery now raises `ServersRetrievalError` rather than returning `{}`.
23
+ - **Multi-gigabit throughput under-reporting** (Home Assistant `#178446`): replaced blocking `urllib` + `10240`-byte reads + `sleep(0.001)` busy-wait loops with native `asyncio` raw TCP and 256 KiB chunked streaming.
24
+ - **Stale `results.timestamp` & `_share` across reused instances:** `SpeedtestResults.touch_timestamp()` refreshes the ISO-8601 UTC timestamp (`datetime.now(UTC)`) and resets cached `_share` on each measurement cycle.
25
+ - **Crash & mutation bugs:** removed dead `DOM.parseString` fallback (`NameError`), non-200 config `None` return (`KeyError: 'client'`), in-place mutation of caller `servers`/`exclude` lists, non-idempotent `get_closest_servers()`, CLI `--exclude` without `--server` `NoMatchedServers` `TypeError`, and bare `Mozilla/5.0` `HTTP 403` rejections.
26
+
27
+ ### Changed
28
+
29
+ - **Minimum Python version:** requires Python `>= 3.11` (all Python 2.4–3.10 compatibility shims removed).
30
+ - **HTTPS by default:** `secure=True` is now the default for both library calls and CLI invocations (`--no-secure` opts into plain HTTP).
31
+ - **Packaging & tooling:** migrated from `setup.py` / `setup.cfg` / `tox.ini` / `.travis.yml` to `uv` + `hatchling` (`pyproject.toml` + `uv.lock`), `ruff`, `mypy --strict`, and standard `logging.getLogger("speedtest")`.
@@ -0,0 +1,39 @@
1
+ # Pull Requests
2
+
3
+ ## Pull requests should be
4
+
5
+ 1. Made against the `devel` branch.
6
+ 1. Made from a git feature branch.
7
+
8
+ ## Pull requests will not be accepted that
9
+
10
+ 1. Are not made against the `devel` branch
11
+ 1. Are submitted from a branch named `devel`
12
+ 1. Do not pass pep8/pyflakes/flake8
13
+ 1. Do not work with Python 2.4-3.4 or pypy
14
+ 1. Add python modules not included with the Python standard library
15
+ 1. Are made by editing files via the GitHub website
16
+
17
+ # Coding Guidelines
18
+
19
+ In general, I follow strict pep8 and pyflakes. All code must pass these tests. Since we support python 2.4-3.4 and pypy, pyflakes reports unknown names in python 3. pyflakes is run in python 2.7 only in my tests.
20
+
21
+ ## Some other points
22
+
23
+ 1. Do not use `\` for line continuations, long strings should be wrapped in `()`. Imports should start a brand new line in the form of `from foo import...`
24
+ 1. String quoting should be done with single quotes `'`, except for situations where you would otherwise have to escape an internal single quote
25
+ 1. Docstrings should use three double quotes `"""`
26
+ 1. All functions, classes and modules should have docstrings following both the PEP257 and PEP8 standards
27
+ 1. Inline comments should only be used on code where it is not immediately obvious what the code achieves
28
+
29
+ # Supported Python Versions
30
+
31
+ All code needs to support Python 2.4-3.4 and pypy.
32
+
33
+ # Permitted Python Modules
34
+
35
+ Only modules included in the standard library are permitted for use in this application. This application should not be dependent on any 3rd party modules that would need to be installed external to just Python itself.
36
+
37
+ # Testing
38
+
39
+ Currently there are no unit tests, but they are planned.
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.