SeleniumHQ/selenium · error · TypeError

service_args must be a sequence

Error message

service_args must be a sequence

What it means

Service.service_args setter rejects a bare str (because a string is technically a Sequence of chars) and any non-sequence; it requires a list/tuple of argument strings and stores a list copy.

Source

Thrown at py/selenium/webdriver/safari/service.py:90

    @property
    def reuse_service(self) -> bool:
        return self._reuse_service

    @reuse_service.setter
    def reuse_service(self, reuse: bool) -> None:
        if not isinstance(reuse, bool):
            raise TypeError("reuse must be a boolean")
        self._reuse_service = reuse

    @property
    def service_args(self) -> Sequence[str]:
        """Returns the sequence of service arguments."""
        return self._service_args

    @service_args.setter
    def service_args(self, value: Sequence[str]):
        if isinstance(value, str) or not isinstance(value, Sequence):
            raise TypeError("service_args must be a sequence")
        self._service_args = list(value)

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Pass a list: service_args=['--port=1234', '--verbose'].
  2. When building from config, ensure the value is a list before assignment.

Example fix

# before
service.service_args = "--port=1234 --verbose"

# after
service.service_args = ["--port=1234", "--verbose"]
Defensive patterns

Strategy: type-guard

Type guard

from collections.abc import Sequence
def is_arg_list(v) -> bool:
    return not isinstance(v, (str, bytes)) and isinstance(v, Sequence)

Prevention

When it happens

Trigger: service.service_args = '--port=1234' (a single string) instead of ['--port=1234'], or assigning an int/None.

Common situations: Passing a single CLI flag as a string by habit, or joining multiple args with spaces into one string.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/956a541df76a19fe. Report an issue: GitHub.