Skip to content

Applies model generics on relational fields functions#2156

Open
ropmyung wants to merge 1 commit intotortoise:developfrom
ropmyung:develop
Open

Applies model generics on relational fields functions#2156
ropmyung wants to merge 1 commit intotortoise:developfrom
ropmyung:develop

Conversation

@ropmyung
Copy link
Copy Markdown

Description

Applied generic syntax on relational fields functions for type hinting

ForeignKeyField
OneToOneField

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 28, 2026

Merging this PR will not alter performance

✅ 24 untouched benchmarks


Comparing ropmyung:develop (0b53759) with develop (e272ab0)

Open in CodSpeed

@waketzheng
Copy link
Copy Markdown
Contributor

Why do that? What's the benefit?

@ropmyung
Copy link
Copy Markdown
Author

ropmyung commented Apr 3, 2026

Why do that? What's the benefit?

Of course for type hint. Otherwise, It shows like Model, not the specific model class

@waketzheng
Copy link
Copy Markdown
Contributor

Could you show a demo of how 'Model' raises a type issue, while 'MODEL' does not?

@ropmyung
Copy link
Copy Markdown
Author

ropmyung commented Apr 4, 2026

Could you show a demo of how 'Model' raises a type issue, while 'MODEL' does not?

class Test1(Model):
    id = fields.BigIntField(pk=True)


class Test2(Model):
    id = fields.BigIntField(pk=True)
    test1 = fields.ForeignKeyField(Test1)
image image

@waketzheng
Copy link
Copy Markdown
Contributor

OK, get it. Seems that the ManyToManyField function in line 587 should be changed as well.

@waketzheng
Copy link
Copy Markdown
Contributor

The following lines should be changed also:
361
384
424
438
450
460
525

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.

2 participants