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

chore: typing fixes for factory-boy 3.3.3 #8501

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions ietf/doc/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import factory.fuzzy
import datetime

from typing import Optional # pyflakes:ignore
from typing import Any # pyflakes:ignore

from django.conf import settings
from django.utils import timezone
Expand Down Expand Up @@ -37,13 +37,16 @@ class Meta:
model = Document
skip_postgeneration_save = True

# n.b., a few attributes are typed as Any so mypy won't complain when we override in subclasses
title = factory.Faker('sentence',nb_words=5)
abstract = factory.Faker('paragraph', nb_sentences=5)
abstract: Any = factory.Faker('paragraph', nb_sentences=5)
rev = '00'
std_level_id = None # type: Optional[str]
std_level_id: Any = None
intended_std_level_id = None
time = timezone.now()
expires = factory.LazyAttribute(lambda o: o.time+datetime.timedelta(days=settings.INTERNET_DRAFT_DAYS_TO_EXPIRE))
expires: Any = factory.LazyAttribute(
lambda o: o.time+datetime.timedelta(days=settings.INTERNET_DRAFT_DAYS_TO_EXPIRE)
)
pages = factory.fuzzy.FuzzyInteger(2,400)


Expand Down Expand Up @@ -282,7 +285,7 @@ class Meta:

type = 'added_comment'
by = factory.SubFactory('ietf.person.factories.PersonFactory')
doc = factory.SubFactory(DocumentFactory)
doc: Any = factory.SubFactory(DocumentFactory) # `Any` to appease mypy when a subclass overrides doc
desc = factory.Faker('sentence',nb_words=6)

@factory.lazy_attribute
Expand Down
2 changes: 1 addition & 1 deletion ietf/ipr/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def test_notify_generic(self):
self.assertIn(f'{settings.IDTRACKER_BASE_URL}{urlreverse("ietf.ipr.views.showlist")}', get_payload_text(outbox[1]).replace('\n',' '))

def send_ipr_email_helper(self) -> tuple[str, IprEvent, HolderIprDisclosure]:
ipr = HolderIprDisclosureFactory()
ipr = HolderIprDisclosureFactory.create() # call create() explicitly so mypy sees correct type
url = urlreverse('ietf.ipr.views.email',kwargs={ "id": ipr.id })
self.client.login(username="secretary", password="secretary+password")
yesterday = date_today() - datetime.timedelta(1)
Expand Down
3 changes: 2 additions & 1 deletion ietf/meeting/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,8 @@ def create_timeslots_url(meeting):
@staticmethod
def create_bare_meeting(number=120) -> Meeting:
"""Create a basic IETF meeting"""
return MeetingFactory(
# Call create() explicitly so mypy sees the correct type
return MeetingFactory.create(
type_id='ietf',
number=number,
date=date_today() + datetime.timedelta(days=10),
Expand Down
Loading