Skip to content

Conversation

@browniebroke
Copy link
Contributor

@browniebroke browniebroke commented Sep 16, 2025

I have made things!

I received and update for mypy 1.17.1 -> 1.18.1 and started to see some failures pointing at code like this in my tests:

class TestAPIView:
    url = reverse_lazy("api:example")

    def test_ok(self, api_client: APIClient):
        ...
        response = api_client.get(self.url)  # Error here
        ...

The error message was:

error: Argument 1 to "get" of "APIClient" has incompatible type "_StrPromise"; expected "str"  [arg-type]

The code runs fine and the type check was ok with it in previous versions. Therefore we can probably safely accept lazy strings as path.

Note: while running the tests it seems like we also need to update the base client class in django-stubs. I'll try to do that at some point when I have more time EDIT: it was due to a suppression comment being on the wrong place.

Related issues

@intgr
Copy link
Contributor

intgr commented Sep 16, 2025

Thanks! You are correct, paths can be lazy.

@browniebroke
Copy link
Contributor Author

Thanks for the comments, super helpful!

@browniebroke browniebroke marked this pull request as ready for review September 16, 2025 16:43
@browniebroke
Copy link
Contributor Author

The stubtest failure seems unrelated... AFAIK it happens on other branches. Seems like an easy fix though

Copy link
Contributor

@intgr intgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@intgr intgr merged commit 4494f82 into typeddjango:master Sep 16, 2025
11 checks passed
@browniebroke browniebroke deleted the api-client-str-promise branch September 16, 2025 19:27
@intgr
Copy link
Contributor

intgr commented Sep 18, 2025

djangorestframework-stubs 3.16.3 released just now with this change.

Release notes: https://github.com/typeddjango/djangorestframework-stubs/releases/tag/3.16.3

@intgr intgr self-assigned this Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants