Skip to content

Type errors when using limit=None for reddit.inbox.unread #2042

@foolo

Description

@foolo

Describe the Bug

Steps:
make a call to reddit.inbox.unread(limit=None), as described in https://praw.readthedocs.io/en/stable/code_overview/reddit/inbox.html#praw.models.Inbox.unread

See code example below.

Observe the type checker errors (from pyright):

praw_hints_example.py:6:39 - error: Argument of type "None" cannot be assigned to parameter "limit" of type "str | int | dict[str, str]" in function "unread"
    Type "None" is not assignable to type "str | int | dict[str, str]"
      "None" is not assignable to "str"
      "None" is not assignable to "int"
      "None" is not assignable to "dict[str, str]" (reportArgumentType)

Or in the IDE:
Screenshot_2025-01-03_09-19-09 (copy 1)

Note: The program runs without crashing but I don't know if it behaves correctly because I don't have an available unread feed which exceeds the default limit of 100.

Desired Result

No type error should show

Code to reproduce the bug

import praw

def example(reddit: praw.Reddit):
    items = reddit.inbox.unread(limit=None)
    for item in items:
        print(item)

My code does not include sensitive credentials

  • Yes, I have removed sensitive credentials from my code.

Relevant Logs

N/A

This code has previously worked as intended

I'm not sure, I haven't used this code before.

Operating System/Environment

Ubuntu 23.10

Python Version

3.11.6

PRAW Version

7.8.1

Links, references, and/or additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions