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

feat: drop support for Python3.8 #1848

Merged
merged 23 commits into from
Jan 21, 2025
Merged

Conversation

waketzheng
Copy link
Contributor

@waketzheng waketzheng commented Jan 10, 2025

Description

Python3.8 already EOL: https://devguide.python.org/versions/

Motivation and Context

Changes:

  • typing.List/Tuple/Set/Dict --> list/tuple/set/dict
  • typing.Callable/Coroutine/Iterable/... --> collections.abc.Callable/Coroutine/Iterable/...
  • functools.lru_cache(maxsize=None) --> functools.cache
  • super(xxx, self) -> super()
  • refactor tortoise.models.ModelMeta to fix codacy issue (python -m mccabe --min 15 tortoise/models.py)

How Has This Been Tested?

make ci

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

codspeed-hq bot commented Jan 10, 2025

CodSpeed Performance Report

Merging #1848 will not alter performance

Comparing waketzheng:drop-py38 (1be0587) with develop (71624e7)

Summary

✅ 8 untouched benchmarks

@coveralls
Copy link

coveralls commented Jan 10, 2025

Pull Request Test Coverage Report for Build 12879310652

Details

  • 352 of 373 (94.37%) changed or added relevant lines in 51 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.8%) to 89.436%

Changes Missing Coverage Covered Lines Changed/Added Lines %
tortoise/connection.py 8 9 88.89%
tortoise/contrib/aiohttp/init.py 0 2 0.0%
tortoise/contrib/mysql/search.py 0 2 0.0%
tortoise/contrib/quart/init.py 0 2 0.0%
tortoise/contrib/sanic/init.py 0 2 0.0%
tortoise/contrib/starlette/init.py 0 2 0.0%
tortoise/backends/oracle/schema_generator.py 3 8 37.5%
tortoise/contrib/pylint/init.py 0 5 0.0%
Totals Coverage Status
Change from base Build 12863458690: -0.8%
Covered Lines: 6484
Relevant Lines: 7067

💛 - Coveralls

@waketzheng waketzheng marked this pull request as draft January 17, 2025 09:02
@waketzheng waketzheng marked this pull request as ready for review January 20, 2025 09:11
Copy link
Contributor

@henadzit henadzit left a comment

Choose a reason for hiding this comment

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

Great job on replacing List, Dict, etc.!

meta.fields_map = fields_map
meta.fields_db_projection = fields_db_projection
meta._filters = filters
meta.fk_fields = fk_fields
meta.backward_fk_fields = set()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are backward_fk_fields, default_connection and other fields are removed from here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because there are defined in MetaInfo.__init__:

self.backward_fk_fields: Set[str] = set()

class ModelMeta(type):
__slots__ = ()
# Searching for Field attributes in the class hierarchy
def _search_for_field_attributes(base: Type, attrs: dict) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be a static method as parse_custom_pk and dispatch_fields, I don't see a reason why we would want to keep it as a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved it into ModelMeta as a classmethod, because it's a recursion function that can not be set as staticmethod.

tortoise/models.py Outdated Show resolved Hide resolved
tortoise/models.py Show resolved Hide resolved
tortoise/models.py Outdated Show resolved Hide resolved
@henadzit henadzit merged commit de48e77 into tortoise:develop Jan 21, 2025
9 checks passed
@waketzheng waketzheng deleted the drop-py38 branch January 22, 2025 06:41
@henadzit henadzit mentioned this pull request Jan 22, 2025
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

Successfully merging this pull request may close these issues.

3 participants