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
Pylance errors for catch_response and name parameters in self.client.get() #2563
Comments
Yea… it sucks, but it is really hard to fix (without wrapping every method). IIRC FastHttpUser is better, if that is any help. |
Any ideas or starting points on the cause? I'm willing to take a crack at it. |
The post/get/… methods are not defined in HttpClient but in its parent, requests.Session. HttpClient only explicitly overrides the generic .request() method ( Line 97 in 6936933
it would need explicit overrides for the specific methods, defining all the arguments. But that is kind of ugly/repetitive. Maybe it can be done in a |
So, I didn't have any luck initially trying to create new methods to wrap get/put with types to make pylance happy, best I could do was keep pushing the pylance errors deeper into the locust code base. I was about to call it quits until I reread you comment and noticed the part about if TYPE_CHECKING:
def get(self, url, name=None, catch_response=False, **kwargs) -> ResponseContextManager:
...
def put(self, url, name=None, catch_response=False, **kwargs) -> ResponseContextManager:
... So, I suppose you could do it a number of ways...depending on how many cases of this there are in the larger codebase, you could define empty classes/methods with typing in a type checking block and then the real ones in the else block (but then you have to worry about keeping them synchonized with eachother)...or alternatively, handle them on a case by case basis by adding them in where necessary similar to the above? In either case, it's something else that would need to be maintained if added, so certainly defer to you on the best approach, or if it's worth the squeeze at all. At the end of the day, I can always add a |
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
When I hover mouse over get methods, to see available parameters it doesn't show appropriate list of parameters and it also sucks 👎 |
Prerequisites
Description
When using 'catch_response' and 'name' paramters in 'self.client.get()', Pylance reports 'No parameter named...' for each. However, the code does function properly as documented/expected. It's possible that this could be an issue with Pylance itself as well.
Command line
locust -f pylance_bug.py
Locustfile contents
Python version
3.11.5
Locust version
2.20.1
Operating system
Red Hat Enterprise Linux 8.9
The text was updated successfully, but these errors were encountered: