Skip to content

Fix pyright type error to assert that actions can't be an int. #1270

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

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

yjhan96
Copy link
Collaborator

@yjhan96 yjhan96 commented Feb 23, 2025

Description

When I ran pre-commit run --all-files locally, there were two pyright errors, and I think the error is valid - numpy doesn't provide enough type context to tell pyright that tolist() will not return a scalar if the instance isn't a scalar. Since np.flatnonzero never returns a scalar, asserting that the return value of tolist() is never an int seems reasonable to fix pyright error.

Fixes #1269 .

Type of change

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have run the pre-commit checks with pre-commit run --all-files (see CONTRIBUTING.md instructions to set it up)
  • I have run pytest -v and no errors are present.
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I solved any possible warnings that pytest -v has generated that are related to my code to the best of my knowledge.
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@yjhan96 yjhan96 added bug Something isn't working python Pull requests that update Python code labels Feb 23, 2025
@yjhan96 yjhan96 added this to the 1.25 release milestone Feb 23, 2025
@yjhan96 yjhan96 self-assigned this Feb 23, 2025
@yjhan96 yjhan96 requested a review from David-GERARD February 23, 2025 21:58
@David-GERARD David-GERARD merged commit f0bd545 into master Feb 25, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Pyright] Pyright complains in random_demo.py and average_total_reward.py
2 participants