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 · 9 comments
Open
1 task done

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

foolo opened this issue Jan 3, 2025 · 9 comments
Labels
⭐️ New Contributor Friendly ⭐️ Good for newcomers Verified Confirmed bug or issue

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 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)

Copy link

This issue is stale because it has been open for 30 days with no activity.

Remove the Stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale Issue or pull request has been inactive for 20 days label Feb 11, 2025
@foolo
Copy link
Author

foolo commented Feb 11, 2025

This issue is stale because it has been open for 30 days with no activity.

Remove the Stale label or comment or this will be closed in 30 days.

Still a relevant issue

@bboe
Copy link
Member

bboe commented Feb 11, 2025

@foolo will you make a pull request that updates the code to have the following:

**generator_kwargs: str | int | dict[str, str] | None,

We don't guarantee pyright will pass, so this change may result in cascading changes.

@bboe bboe added ⭐️ New Contributor Friendly ⭐️ Good for newcomers Verified Confirmed bug or issue and removed Stale Issue or pull request has been inactive for 20 days labels Feb 11, 2025
@foolo
Copy link
Author

foolo commented Feb 11, 2025

@foolo will you make a pull request that updates the code to have the following:

**generator_kwargs: str | int | dict[str, str] | None,

We don't guarantee pyright will pass, so this change may result in cascading changes.

Thanks for replying! Though I don't really know how to test it all and fix any cascading changes it may cause (or have time to figure it out).
I mean, I could just blindly change that one line without testing anything, but I assume that's not what your'e asking for :)

@bboe
Copy link
Member

bboe commented Feb 11, 2025

I mean, I could just blindly change that one line without testing anything, but I assume that's not what your'e asking for :)

Yeah, you're right that I'm not quite asking for that. While we can fix this one error to make pyright happy in this particular case, it's likely to cause a cascading issue, which may or may not be visible to end-users. As a result, pyright presently remains in an unsupported state. I happen to be doing some work to address type checking related issues as reported by ruff, but I am not optimistic that I'll be able to address all the pyright issues in this package.

@foolo
Copy link
Author

foolo commented Feb 12, 2025

I mean, I could just blindly change that one line without testing anything, but I assume that's not what your'e asking for :)

Yeah, you're right that I'm not quite asking for that. While we can fix this one error to make pyright happy in this particular case, it's likely to cause a cascading issue, which may or may not be visible to end-users. As a result, pyright presently remains in an unsupported state. I happen to be doing some work to address type checking related issues as reported by ruff, but I am not optimistic that I'll be able to address all the pyright issues in this package.

Fully understand. This is not a blocker in any way. Just need to add # type: ignore here and there and the problem is "gone" :) I just felt that I should report it in case you want to fix it.

@arjunprakash027
Copy link

Is this issue still relevant?
If yes, I can pick up and fix any cascading changes

@alythobani
Copy link

Is this issue still relevant?

I believe it is yeah. Still seems to be no issues on the dev side with adding a # type: ignore to it though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⭐️ New Contributor Friendly ⭐️ Good for newcomers Verified Confirmed bug or issue
Projects
None yet
Development

No branches or pull requests

4 participants