Skip to content

Commit 33e8733

Browse files
committed
Fixed up mypy issues or added type:ignore comments as needed for a clean mypy run.
- Legacy-Id: 16772
1 parent c15b3e1 commit 33e8733

51 files changed

Lines changed: 169 additions & 82 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

debug.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import sys
44
import time as timeutils
55
import inspect
6+
import six
7+
if six.PY3:
8+
from typing import Callable
69

710
try:
811
import syslog
9-
logger = syslog.syslog
12+
logger = syslog.syslog # type: Callable
1013
except ImportError: # import syslog will fail on Windows boxes
1114
import logging
1215
logging.basicConfig(filename='tracker.log',level=logging.INFO)
@@ -15,7 +18,7 @@
1518
try:
1619
from pprint import pformat
1720
except ImportError:
18-
pformat = lambda x: x
21+
pformat = lambda x: x # type: ignore
1922

2023
import cProfile
2124
import traceback as tb

ietf/checks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66

77
import os
88
import patch
9+
import six
910
import sys
1011
import time
1112
from textwrap import dedent
13+
if six.PY3:
14+
from typing import List, Tuple # pyflakes:ignore
1215

1316
import debug # pyflakes:ignore
1417
debug.debug = True
@@ -17,7 +20,7 @@
1720
from django.core import checks
1821
from django.utils.module_loading import import_string
1922

20-
checks_run = []
23+
checks_run = [] # type: List[str]
2124

2225
def already_ran():
2326
import inspect

ietf/community/migrations/0001_initial.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
# Generated by Django 1.11.10 on 2018-02-20 10:52
44
from __future__ import absolute_import, print_function, unicode_literals
55

6+
import six
7+
if six.PY3:
8+
from typing import List # pyflakes:ignore
9+
610
from django.db import migrations, models
711
import django.db.models.deletion
812
import ietf.utils.models
@@ -13,7 +17,7 @@ class Migration(migrations.Migration):
1317
initial = True
1418

1519
dependencies = [
16-
]
20+
] # type: List[str]
1721

1822
operations = [
1923
migrations.CreateModel(

ietf/dbtemplate/migrations/0001_initial.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55

66
from __future__ import absolute_import, print_function, unicode_literals
77

8+
import six
9+
if six.PY3:
10+
from typing import List # pyflakes:ignore
11+
812
from django.db import migrations, models
913

1014

@@ -13,7 +17,7 @@ class Migration(migrations.Migration):
1317
initial = True
1418

1519
dependencies = [
16-
]
20+
] # type: List[str]
1721

1822
operations = [
1923
migrations.CreateModel(

ietf/dbtemplate/template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import debug # pyflakes:ignore
1212

1313
from django.template.loaders.base import Loader as BaseLoader
14-
from django.template.base import Template as DjangoTemplate, TemplateEncodingError
14+
from django.template.base import Template as DjangoTemplate, TemplateEncodingError # type: ignore (FIXME: remove when Django 2)
1515
from django.template.exceptions import TemplateDoesNotExist
1616
from django.utils.encoding import smart_text
1717

@@ -95,4 +95,4 @@ def load_template_source(template_name, template_dirs=None):
9595
PendingDeprecationWarning
9696
)
9797
return _loader.load_template_source(template_name, template_dirs)
98-
load_template_source.is_usable = True
98+
load_template_source.is_usable = True # type: ignore # https://github.com/python/mypy/issues/2087

ietf/doc/expire.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
from django.conf import settings
99

1010
import datetime, os, shutil, glob, re
11+
import six
1112
from pathlib import Path
13+
if six.PY3:
14+
from typing import List, Tuple # pyflakes:ignore
1215

1316
from ietf.utils import log
1417
from ietf.utils.mail import send_mail
@@ -28,7 +31,7 @@ def expirable_draft(draft):
2831
log.assertion('draft.get_state_slug("draft-iesg")')
2932
return bool(expirable_drafts(Document.objects.filter(pk=draft.pk)))
3033

31-
nonexpirable_states = []
34+
nonexpirable_states = [] # type: List[State]
3235

3336
def expirable_drafts(queryset=None):
3437
"""Return a queryset with expirable drafts."""

ietf/doc/factories.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import debug # pyflakes:ignore
88
import factory
99
import datetime
10+
import six
11+
if six.PY3:
12+
from typing import Optional # pyflakes:ignore
1013

1114
from django.conf import settings
1215

@@ -28,7 +31,7 @@ class Meta:
2831

2932
title = factory.Faker('sentence',nb_words=5)
3033
rev = '00'
31-
std_level_id = None
34+
std_level_id = None # type: Optional[str]
3235
intended_std_level_id = None
3336
time = datetime.datetime.now()
3437
expires = factory.LazyAttribute(lambda o: o.time+datetime.timedelta(days=settings.INTERNET_DRAFT_DAYS_TO_EXPIRE))

ietf/doc/feeds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
from django.contrib.syndication.views import Feed, FeedDoesNotExist
1111
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
1212
from django.urls import reverse as urlreverse
13-
from django.template.defaultfilters import truncatewords, truncatewords_html, date as datefilter, linebreaks
13+
from django.template.defaultfilters import truncatewords, truncatewords_html, date as datefilter
14+
from django.template.defaultfilters import linebreaks # type: ignore
1415
from django.utils.html import strip_tags
1516

1617
from ietf.doc.models import Document, State, LastCallDocEvent, DocEvent

ietf/doc/views_search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from django.db.models import Q
4747
from django.http import Http404, HttpResponseBadRequest, HttpResponse, HttpResponseRedirect, QueryDict
4848
from django.shortcuts import render
49-
from django.utils.cache import _generate_cache_key
49+
from django.utils.cache import _generate_cache_key # type: ignore (FIXME: remove when Django 2)
5050

5151

5252
import debug # pyflakes:ignore

ietf/doc/views_status_change.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import io
99
import os
1010
import re
11+
import six
12+
if six.PY3:
13+
from typing import Dict # pyflakes:ignore
1114

1215
from django import forms
1316
from django.shortcuts import render, get_object_or_404, redirect
@@ -435,7 +438,7 @@ def clean_helper(form, formtype):
435438
return cleaned_data
436439

437440
class EditStatusChangeForm(forms.Form):
438-
relations={}
441+
relations={} # type: Dict[str, str]
439442

440443
def __init__(self, *args, **kwargs):
441444
super(self.__class__, self).__init__(*args, **kwargs)
@@ -452,7 +455,7 @@ class StartStatusChangeForm(forms.Form):
452455
create_in_state = forms.ModelChoiceField(State.objects.filter(type="statchg", slug__in=("needshep", "adrev")), empty_label=None, required=False)
453456
notify = forms.CharField(max_length=255, label="Notice emails", help_text="Separate email addresses with commas.", required=False)
454457
telechat_date = forms.TypedChoiceField(coerce=lambda x: datetime.datetime.strptime(x, '%Y-%m-%d').date(), empty_value=None, required=False, widget=forms.Select(attrs={'onchange':'make_bold()'}))
455-
relations={}
458+
relations={} # type: Dict[str, str]
456459

457460
def __init__(self, *args, **kwargs):
458461
super(self.__class__, self).__init__(*args, **kwargs)

0 commit comments

Comments
 (0)