Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
foolo opened this issue Jan 3, 2025 · 1 comment
Open
1 task done

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

foolo opened this issue Jan 3, 2025 · 1 comment

Comments

@foolo
Copy link

foolo commented Jan 3, 2025

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

@praw-dev praw-dev deleted a comment from ZakariaMQ Jan 10, 2025
@foolo
Copy link
Author

foolo commented Jan 12, 2025

Another note, in strict mode ("python.analysis.typeCheckingMode": "strict" in .vscode/settings.json) there are some warnings about missing stub files for praw.
Screenshot_2025-01-12_07-52-09 (copy 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant