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

Fix little problem with type hints and adopt a test to make sure it works in all platform #1207

Merged
merged 9 commits into from Jun 19, 2023

Conversation

Zoupers
Copy link
Contributor

@Zoupers Zoupers commented May 6, 2023

Checklist:

  • Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
  • Add or update relevant docs, in the docs folder and in code.
  • Add an entry in CHANGES.rst summarizing the change and linking to the issue.
  • Add .. versionchanged:: entries in any relevant code docs.
  • Run pre-commit hooks and fix any issues.
  • Run pytest and tox, no tests failed.

Delete line means I think there is no need to do that.

@pamelafox
Copy link
Contributor

@Zoupers Is this ready for review? And can you specify in the description or inline, which test is the one that didn't work on Windows?

from flask import abort

from .pagination import Pagination
from .pagination import QueryPagination


class Query(sa.orm.Query): # type: ignore[type-arg]
class Query(sa_orm.Query[t.Any]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this, https://github.com/sqlalchemy/sqlalchemy/blob/4808acfe1b88854fce47b792ef9995f1921426e7/lib/sqlalchemy/orm/query.py#L77
which is the version(1.4.18) specified in the requirements/tests-min.in, it's not correct. I will fix it.

@@ -24,5 +26,5 @@ class Example(db.Model):
assert "FROM example" in info.statement
assert info.parameters[0][0] == 5
assert info.duration == info.end_time - info.start_time
assert "tests/test_record_queries.py:" in info.location
assert os.path.join("tests", "test_record_queries.py:") in info.location
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume this is the test that did not previously work in Windows.

@Zoupers
Copy link
Contributor Author

Zoupers commented Jun 19, 2023

I have fixed the bug and passed the corresponding tests locally. I apologize for any inconvenience caused.

@Zoupers Zoupers requested a review from pamelafox June 19, 2023 16:24
@pamelafox
Copy link
Contributor

@Zoupers Thanks! I think we may upgrade min version of SQLAlchemy to 2.0 in the next version in order to formally support it, but for this minor release, it's better to just get it working for 1.4. This is looking good now.

@pamelafox
Copy link
Contributor

I experimented a bit to see if we could automatically test that this works correctly, but we're not currently running pyright on the code, and if we did, we'd have a bunch of other issues that can't be ignored as easily as they are in mypy (as pyright doesn't have the same specific error codes), so I think it's fine to not have a test for the pyright-specific typing right now.

However, if there's a regression in the future, we might consider adding pyright env to tox.

@pamelafox pamelafox merged commit f71838f into pallets-eco:3.0.x Jun 19, 2023
9 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants