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

Remove typing from CspRenderingTestCase #2087

Open
tim-schilling opened this issue Feb 26, 2025 · 5 comments
Open

Remove typing from CspRenderingTestCase #2087

tim-schilling opened this issue Feb 26, 2025 · 5 comments

Comments

@tim-schilling
Copy link
Member

I'd be in favor of removing the typing on CspRenderingTestCase. I'm not in favor of utilizing type hinting to that extent.

I know we have an issue to bring typing to the library, but I'm not sure I'm in agreement with that any more. The type hinting below seems to only be beneficial to a particular developer set up that we don't have documented anywhere. I think that inconsistency isn't worth it.

response = cast(HttpResponse, self.client.get(path="/regular/basic/"))
self.assertEqual(response.status_code, 200)

html_root: Element = self.parser.parse(stream=response.content)
self._fail_on_invalid_html(content=response.content, parser=self.parser)
self.assertContains(response, "djDebug")

namespaces = get_namespaces(element=html_root)
context: ContextList = response.context  # pyright: ignore[reportAttributeAccessIssue]
@matthiask
Copy link
Member

I'm not profiting from typing at all currently but I also think the Python world is slowly moving towards it.

If the types keep us from fixing issues we have I agree that removing them is the right thing to do.

Maybe my stance will change once we get the type checker integrated into ruff, I don't know. I do expect that one to make a difference.

@tim-schilling
Copy link
Member Author

If the types keep us from fixing issues we have I agree that removing them is the right thing to do.

It's not getting in the way, but I can't maintain the typing code for that because I'm not set up for it. It's not something I'm interested in investing a significant amount of time into right now either.

@matthiask
Copy link
Member

It's not something I'm interested in investing a significant amount of time into right now either.

Me neither! It seems we really should be the ones profiting from the typing effort. Since we're not I now totally agree with the removal.

@karolyi
Copy link
Contributor

karolyi commented Mar 9, 2025

Just my 2 cents: if it doesn't bother your environment, why would you lessen someone else's experience with the code, when it comes to writing tests? If nobody forces you to write typed code, why would you force someone else to write untyped code?

For the record: I'm using basedpyright and I've learned how to write code immensely more stable just by utilizing proper typing. Yes it is a hassle at first but totally worth it on the long run. Maybe it's the same reason why python is moving towards it.

Feel free to do as you like, I just wanted to put in an opposing opinion/counterargument.

@tim-schilling
Copy link
Member Author

tim-schilling commented Mar 11, 2025

Thank you for your opinion. The earlier discussion should cover the questions you asked. When I make the time to invest into heavily typed python, I'll probably regret this decision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants