Skip to content

BaseConnector limit if of type int but documentation suggests None as an option #8514

@nono1515

Description

@nono1515

Describe the bug

aiohttp.BaseConnector has an option limit which is an int according to Python typing. However, the doc mentions limit (int – total number simultaneous connections. If limit is None the connector has no limit (default: 100).. Then, when setting this option to None, Mypy complains
Argument "limit" to "TCPConnector" has incompatible type "None"; expected "int" - mypy arg-type
Proposed solution: set the type value of limit to Optionnal[int] or int | None in BaseConnector and other connectors

To Reproduce

# main.py
connector = aiohttp.TCPConnector(limit=None)
$ mypy main.py
error: Argument "limit" to "TCPConnector" has incompatible type "None"; expected "int"  [arg-type]

Expected behavior

Mypy raises no error.

Logs/tracebacks

error: Argument "limit" to "TCPConnector" has incompatible type "None"; expected "int"  [arg-type]

Python Version

$ python --version
Python 3.11.8

aiohttp Version

$ python -m pip show aiohttp
Name: aiohttp
Version: 3.9.3
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 6.0.5
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict

yarl Version

$ python -m pip show yarl
Name: yarl
Version: 1.9.4
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl

OS

WSL Ubuntu on Windows 10

Related component

Client

Additional context

No response

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions