arduino/Arduino · error · NotImplemented

Classes extending RequestMethods must implement their own ``

Error message

Classes extending RequestMethods must implement their own ``urlopen`` method.

What it means

RequestMethods.urlopen is an abstract method: the base class defines the request/request_encode_url/request_encode_body helpers but requires subclasses (like PoolManager or HTTPConnectionPool) to implement urlopen. Calling urlopen (directly or via request()) on a subclass that did not implement it raises this NotImplemented error.

Source

Thrown at arduino-core/src/processing/app/i18n/python/requests/packages/urllib3/request.py:56

    the request.

    Initializer parameters:

    :param headers:
        Headers to include with all requests, unless other headers are given
        explicitly.
    """

    _encode_url_methods = set(['DELETE', 'GET', 'HEAD', 'OPTIONS'])
    _encode_body_methods = set(['PATCH', 'POST', 'PUT', 'TRACE'])

    def __init__(self, headers=None):
        self.headers = headers or {}

    def urlopen(self, method, url, body=None, headers=None,
                encode_multipart=True, multipart_boundary=None,
                **kw): # Abstract
        raise NotImplemented("Classes extending RequestMethods must implement "
                             "their own ``urlopen`` method.")

    def request(self, method, url, fields=None, headers=None, **urlopen_kw):
        """
        Make a request using :meth:`urlopen` with the appropriate encoding of
        ``fields`` based on the ``method`` used.

        This is a convenience method that requires the least amount of manual
        effort. It can be used in most situations, while still having the option
        to drop down to more specific methods when necessary, such as
        :meth:`request_encode_url`, :meth:`request_encode_body`,
        or even the lowest level :meth:`urlopen`.
        """
        method = method.upper()

        if method in self._encode_url_methods:
            return self.request_encode_url(method, url, fields=fields,
                                            headers=headers,

View on GitHub (pinned to a0df6e0e83)

Solutions

  1. Use a concrete class instead: urllib3.PoolManager() or HTTPConnectionPool(host).
  2. If you subclass RequestMethods, implement urlopen(self, method, url, ...) with your send logic.
  3. Check that your mock/stub in tests implements urlopen (or subclasses PoolManager and overrides it).

Example fix

// before
class MyClient(urllib3.request.RequestMethods):
    pass
MyClient().request('GET', 'https://example.com')  # NotImplemented
// after
class MyClient(urllib3.request.RequestMethods):
    def urlopen(self, method, url, body=None, headers=None, **kw):
        return self._pool.urlopen(method, url, body=body, headers=headers, **kw)
Defensive patterns

Strategy: type-guard

Validate before calling

if isinstance(client, urllib3.request.RequestMethods) and type(client).urlopen is urllib3.request.RequestMethods.urlopen:
    raise TypeError('client must implement urlopen(); use PoolManager or override urlopen')

Type guard

import inspect, urllib3
def implements_urlopen(obj) -> bool:
    fn = type(obj).urlopen
    return not getattr(fn, '__isabstractmethod__', False) and inspect.getsourcefile(urllib3.request.RequestMethods.urlopen) != getattr(fn, '__code__', None) or fn is not urllib3.request.RequestMethods.urlopen

Try / catch

try:
    resp = client.urlopen('GET', url)
except NotImplementedError:
    client = urllib3.PoolManager()
    resp = client.urlopen('GET', url)

Prevention

When it happens

Trigger: Subclassing urllib3.request.RequestMethods and forgetting to override urlopen, then calling instance.request('GET', url) or instance.urlopen('GET', url); calling urlopen on a bare RequestMethods() instance.

Common situations: Custom pool/pool-manager implementations for testing or mocking that only implement part of the interface; code refactored to extend RequestMethods directly; calling request() on an abstract base instantiated by mistake.

Understand the failure class

Background: "NotImplementedError: Subclasses should override this method" / "must be implemented" — abstract method errors explained — this error's family across 40 libraries.

Related errors


AI-assisted analysis of arduino/Arduino@a0df6e0e83 (2026-09-06). Data as JSON: /api/errors/61ea7a6dc715a3c9. Report an issue: GitHub.