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

[ BUG ] Pylance throwing reportAttributeAccessIssue when using pythonic=True #1274

Open
mew1033 opened this issue Jan 21, 2025 · 4 comments
Open
Assignees
Labels
bug 🐛 Something isn't working python Pull requests that update Python code or general Python related questions

Comments

@mew1033
Copy link

mew1033 commented Jan 21, 2025

Describe the bug
When I set pythonic=True in my client and do a query, the response object doesn't appear to properly support type hinting.

To Reproduce

from falconpy import SpotlightVulnerabilities

CID = "client_id"
CSE = "client_secret"
FILTER_STR = "filter_string"

falcon = SpotlightVulnerabilities(client_id=CID, client_secret=CSE, pythonic=True)
res = falcon.query_vulnerabilities_combined(filter=FILTER_STR, limit=1)
rate_limit = res.ratelimit_remaining
resources = res.resources
after = res.after

The last three lines make Pylance unhappy. They say:

Cannot access attribute "ratelimit_remaining" for class "Dict[str, int | dict[Unknown, Unknown]]"
  Attribute "ratelimit_remaining" is unknownPylance[reportAttributeAccessIssue](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportAttributeAccessIssue)

Expected behavior
I expect VSCode/Pylance to find the appropriate symbols and be happy.

Environment (please complete the following information):

  • OS: Ubuntu 22.04 in WSL 2
  • Python: 3.12
  • FalconPy: 1.4.6

Image

@mew1033 mew1033 added the bug 🐛 Something isn't working label Jan 21, 2025
@jshcodes jshcodes self-assigned this Jan 28, 2025
@jshcodes jshcodes added question ❓ Further information is requested python Pull requests that update Python code or general Python related questions investigating This issue is being investigated and removed bug 🐛 Something isn't working labels Jan 28, 2025
@jshcodes
Copy link
Member

jshcodes commented Jan 28, 2025

Hi @mew1033 -

Thanks for reporting this issue!

If you type your result object, does the Pylance error go away? (Currently the type hint for the return of API operation methods do not speak to the pythonic Result object.)

from falconpy import SpotlightVulnerabilities, Result

CID = "client_id"
CSE = "client_secret"

filter_string = "whatevers"

falcon = SpotlightVulnerabilities(pythonic=True)

res: Result = falcon.query_vulnerabilities(filter=filter_string)

rate_limit = res.ratelimit_remaining
resources = res.resources
after = res.after
Image

@jshcodes jshcodes added bug 🐛 Something isn't working and removed question ❓ Further information is requested investigating This issue is being investigated labels Jan 28, 2025
@mew1033
Copy link
Author

mew1033 commented Jan 28, 2025

Looks like it's still erroring for me:

Image

@jshcodes
Copy link
Member

Can you provide us a redacted version of your code so we can test? (Please remove any API keys and CID / AID values.)

@mew1033
Copy link
Author

mew1033 commented Feb 4, 2025

@jshcodes It actually looks like it does fix some of the errors. But it causes additional errors? Strange. Here's a code sample that uses the total, after, and resources properties:

from falconpy import SpotlightVulnerabilities, Result


API_ENDPOINT = "https://apiendpoint"
CLIENT_ID = "id"
CLIENT_SECRET = "secret"

falcon = SpotlightVulnerabilities(client_id=CLIENT_ID, client_secret=CLIENT_SECRET, pythonic=True)

filter_str = "filter_string"
results = []
total = 0
res = falcon.query_vulnerabilities_combined(filter=filter_str, limit=5000)
total += res.total
if (aft := res.after):
    while aft:
        res = falcon.query_vulnerabilities_combined(filter=filter_str, after=aft, limit=5000)
        results.extend(res.resources)
        aft = res.after

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 or general Python related questions
Projects
None yet
Development

No branches or pull requests

2 participants