You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adopt comprehensive Python type hints across the proxybroker codebase (currently ~5% covered) so contributors get accurate IDE autocomplete, static type checking via mypy/pyright, and self-documenting public APIs.
Rest of the codebase has none. Public API surface (Broker, Proxy, Resolver, Checker, Server) is fully untyped.
Pyright in default mode flags hundreds of "possibly unbound" / "attribute access" warnings on the existing code, indicating real type ambiguity that hints would resolve.
Built-in collections (list[str], dict[str, int]) — same rationale.
from __future__ import annotations at the top of each module to defer evaluation and avoid runtime cost.
Protocols over ABCs for callable interfaces (e.g., Negotiator protocol) where it reduces coupling.
Mypy strictness ramp-up
Start with mypy --strict-optional (catches None bugs); progress to --strict after baseline coverage. Add a CI job (matrix dim or separate workflow) that runs mypy and fails on regressions. Don't enable strict mode globally upfront — gradual adoption per-module is the only realistic path.
Acceptance criteria
All public APIs (everything not prefixed with _) have type hints.
Pyright's reportGeneralTypeIssues count for proxybroker/ drops below 10 (currently ~50+).
New CI job: mypy proxybroker/ runs on every PR; fails on regression.
Internal types (e.g., _NewcomerProxy) typed where they reduce ambiguity at call sites.
README + docs updated to mention type-hint coverage as part of the contributor experience.
Estimated effort
~6-10 hours for the full coverage pass (mostly mechanical).
~2 hours to set up mypy CI + baseline configuration.
1 hour for docs.
Suggest splitting by module into 5-6 PRs of ~1-2 hours each, so each lands cleanly without a giant review burden.
Why this matters
Refactor confidence: mypy catches "you renamed this method but missed 3 call sites" before runtime.
Onboarding: new contributors instantly understand def find(types, limit) is def find(types: list[str], limit: int) -> AsyncIterator[Proxy].
IDE quality: autocomplete + jump-to-definition work correctly. Currently proxy.<TAB> shows everything; with hints it's targeted.
Future-proof: the Python ecosystem has fully embraced typing; untyped libraries are increasingly the outliers.
Goal
Adopt comprehensive Python type hints across the proxybroker codebase (currently ~5% covered) so contributors get accurate IDE autocomplete, static type checking via mypy/pyright, and self-documenting public APIs.
Current state
canonicalize_ip,find_proxy_pairs,_format_host_port.Scope
Add type hints to all public APIs in:
proxybroker/api.pyBroker.__init__,find,grab,serve,stopproxybroker/proxy.pyProxy.__init__,Proxy.create,Proxy.connect,as_text,as_json, propertiesproxybroker/resolver.pyResolver.__init__,host_is_ip,resolve,get_real_ext_ip,get_ip_infoproxybroker/checker.pyChecker,_check_test_response,_get_anonymity_lvlproxybroker/server.pyServer.__init__,start,stopproxybroker/judge.pyJudge,get_judgesproxybroker/providers.pyProviderbase + concrete impls' public methodsproxybroker/provider_utils.pyproxybroker/negotiators.pyBaseNegotiator.negotiatesignaturesproxybroker/utils.pyproxybroker/errors.pyConventions
str | None, notOptional[str]) — already adopted in feat(ipv6): full IPv6 support across the stack (#201) #212; project supports Python 3.10+.list[str],dict[str, int]) — same rationale.from __future__ import annotationsat the top of each module to defer evaluation and avoid runtime cost.Negotiatorprotocol) where it reduces coupling.Mypy strictness ramp-up
Start with
mypy --strict-optional(catchesNonebugs); progress to--strictafter baseline coverage. Add a CI job (matrix dim or separate workflow) that runs mypy and fails on regressions. Don't enable strict mode globally upfront — gradual adoption per-module is the only realistic path.Acceptance criteria
_) have type hints.reportGeneralTypeIssuescount forproxybroker/drops below 10 (currently ~50+).mypy proxybroker/runs on every PR; fails on regression._NewcomerProxy) typed where they reduce ambiguity at call sites.Estimated effort
Suggest splitting by module into 5-6 PRs of ~1-2 hours each, so each lands cleanly without a giant review burden.
Why this matters
def find(types, limit)isdef find(types: list[str], limit: int) -> AsyncIterator[Proxy].proxy.<TAB>shows everything; with hints it's targeted.