darrenburns / posting

The modern API client that lives in your terminal.
Apache License 2.0
4.48k stars 64 forks source link

Crash on startup - unsupported operand type(s) #87

Closed Rasmus-Bertell closed 4 weeks ago

Rasmus-Bertell commented 4 weeks ago

I get the following trying to run posting directly after installing. I'm running archlinux on WSL.

❯ posting
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /usr/lib/python3.12/site-packages/textual/widget.py:3816 in _compose                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                                                                 │
│   3813 │                                                                                        ╭──────── locals ─────────╮                                                                                                                                                                     │
│   3814 │   async def _compose(self) -> None:                                                    │ self = RequestOptions() │                                                                                                                                                                     │
│   3815 │   │   try:                                                                             ╰─────────────────────────╯                                                                                                                                                                     │
│ ❱ 3816 │   │   │   widgets = [*self._pending_children, *compose(self)]                                                                                                                                                                                                                          │
│   3817 │   │   │   self._pending_children.clear()                                                                                                                                                                                                                                               │
│   3818 │   │   except TypeError as error:                                                                                                                                                                                                                                                       │
│   3819 │   │   │   raise TypeError(                                                                                                                                                                                                                                                             │
│                                                                                                                                                                                                                                                                                                 │
│ /usr/lib/python3.12/site-packages/posting/widgets/request/request_options.py:106 in compose                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                                                                 │
│   103 │   │                                                                                    ╭──────── locals ─────────╮                                                                                                                                                                      │
│   104 │   │   with Vertical(id="timeout-option"):                                              │ self = RequestOptions() │                                                                                                                                                                      │
│   105 │   │   │   yield Label("Timeout")                                                       ╰─────────────────────────╯                                                                                                                                                                      │
│ ❱ 106 │   │   │   yield VariableInput(                                                                                                                                                                                                                                                          │
│   107 │   │   │   │   value=str(self.options.timeout),                                                                                                                                                                                                                                          │
│   108 │   │   │   │   id="timeout",                                                                                                                                                                                                                                                             │
│   109 │   │   │   │   type="number",                                                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                                                                 │
│ /usr/lib/python3.12/site-packages/textual/widgets/_input.py:304 in __init__                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                                                                                 │
│   301 │   │   │   self.validators = list(validators)                                           ╭───────────────── locals ──────────────────╮                                                                                                                                                    │
│   302 │   │                                                                                    │     classes = None                        │                                                                                                                                                    │
│   303 │   │   self.validate_on: set[str] = (                                                   │    disabled = False                       │                                                                                                                                                    │
│ ❱ 304 │   │   │   (_POSSIBLE_VALIDATE_ON_VALUES & cast("set[str]", validate_on))               │ highlighter = None                        │                                                                                                                                                    │
│   305 │   │   │   if validate_on is not None                                                   │          id = 'timeout'                   │                                                                                                                                                    │
│   306 │   │   │   else _POSSIBLE_VALIDATE_ON_VALUES                                            │  max_length = 0                           │                                                                                                                                                    │
│   307 │   │   )                                                                                │        name = None                        │                                                                                                                                                    │
│                                                                                                │    password = False                       │                                                                                                                                                    │
│                                                                                                │ placeholder = ''                          │                                                                                                                                                    │
│                                                                                                │    restrict = None                        │                                                                                                                                                    │
│                                                                                                │        self = VariableInput(id='timeout') │                                                                                                                                                    │
│                                                                                                │   suggester = None                        │                                                                                                                                                    │
│                                                                                                │     tooltip = None                        │                                                                                                                                                    │
│                                                                                                │        type = 'number'                    │                                                                                                                                                    │
│                                                                                                │ valid_empty = False                       │                                                                                                                                                    │
│                                                                                                │ validate_on = ['changed']                 │                                                                                                                                                    │
│                                                                                                │  validators = None                        │                                                                                                                                                    │
│                                                                                                │       value = '5.0'                       │                                                                                                                                                    │
│                                                                                                ╰───────────────────────────────────────────╯                                                                                                                                                    │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: unsupported operand type(s) for &: 'set' and 'list'

The above exception was the direct cause of the following exception:

╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ /usr/lib/python3.12/site-packages/textual/widget.py:3819 in _compose                                                                                                                                                                                                                            │
│                                                                                                                                                                                                                                                                                                 │
│   3816 │   │   │   widgets = [*self._pending_children, *compose(self)]                          ╭──────── locals ─────────╮                                                                                                                                                                     │
│   3817 │   │   │   self._pending_children.clear()                                               │ self = RequestOptions() │                                                                                                                                                                     │
│   3818 │   │   except TypeError as error:                                                       ╰─────────────────────────╯                                                                                                                                                                     │
│ ❱ 3819 │   │   │   raise TypeError(                                                                                                                                                                                                                                                             │
│   3820 │   │   │   │   f"{self!r} compose() method returned an invalid result; {error}"                                                                                                                                                                                                         │
│   3821 │   │   │   ) from error                                                                                                                                                                                                                                                                 │
│   3822 │   │   except Exception as error:                                                                                                                                                                                                                                                       │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: RequestOptions() compose() method returned an invalid result; unsupported operand type(s) for &: 'set' and 'list'

System info:

package version
posting 1.10.1
python 3.12.4
darrenburns commented 4 weeks ago

Thanks for the report.

Please install the latest version of Posting. This is a bug in Textual and I've put a workaround in Posting 1.11.0.