mirror of https://github.com/zulip/zulip.git
mypy: Remove a bunch of now-unnecessary type: ignore annotations.
Since mypy and typeshed have advanced a lot over the last several months, we no longer need these `type: ignore` annotations.
This commit is contained in:
parent
3b0b65c2d0
commit
4a4664d268
|
@ -817,7 +817,7 @@ def realm_user_summary_table(all_records, admin_emails):
|
|||
|
||||
def is_recent(val):
|
||||
# type: (Optional[datetime]) -> bool
|
||||
age = datetime.now(val.tzinfo) - val # type: ignore # datetie.now tzinfo bug.
|
||||
age = datetime.now(val.tzinfo) - val
|
||||
return age.total_seconds() < 5 * 60
|
||||
|
||||
rows = []
|
||||
|
|
|
@ -71,7 +71,7 @@ except ImportError:
|
|||
sys.exit(1)
|
||||
try:
|
||||
import requests
|
||||
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1')) # type: ignore # https://github.com/JukkaL/mypy/issues/1165
|
||||
assert(LooseVersion(requests.__version__) >= LooseVersion('0.12.1'))
|
||||
except (ImportError, AssertionError):
|
||||
print("requests >=0.12.1 is not installed", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
|
|
@ -11,5 +11,5 @@ BASE_DIR = dirname(dirname(dirname(abspath(__file__))))
|
|||
activate_this = os.path.join(BASE_DIR, "zulip-venv", "bin", "activate_this.py")
|
||||
if os.path.exists(activate_this):
|
||||
# this file will exist in production
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this))
|
||||
sys.path.append(BASE_DIR)
|
||||
|
|
|
@ -217,7 +217,7 @@ def setup_virtualenv(target_venv_path, requirements_file, virtualenv_args=None,
|
|||
if patch_activate_script:
|
||||
do_patch_activate_script(target_venv_path)
|
||||
activate_this = os.path.join(cached_venv_path, "bin", "activate_this.py")
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this))
|
||||
return cached_venv_path
|
||||
|
||||
def do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):
|
||||
|
@ -238,7 +238,7 @@ def do_setup_virtualenv(venv_path, requirements_file, virtualenv_args):
|
|||
create_requirements_index_file(venv_path, requirements_file)
|
||||
# Switch current Python context to the virtualenv.
|
||||
activate_this = os.path.join(venv_path, "bin", "activate_this.py")
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this)) # type: ignore # https://github.com/python/mypy/issues/1577
|
||||
exec(open(activate_this).read(), {}, dict(__file__=activate_this))
|
||||
|
||||
run(["pip", "install", "-U", "setuptools"])
|
||||
run(["pip", "install", "--upgrade", "pip", "wheel"])
|
||||
|
|
|
@ -77,7 +77,7 @@ def code_point_to_file_name_map(ttx):
|
|||
"""
|
||||
result = {} # type: Dict[int, Union[text_type, bytes]]
|
||||
xml = ET.parse(ttx)
|
||||
for elem in xml.find("*cmap_format_12"): # type: ignore # https://github.com/python/typeshed/pull/254
|
||||
for elem in xml.find("*cmap_format_12"):
|
||||
code_point = int(elem.attrib["code"], 16)
|
||||
fname = elem.attrib["name"]
|
||||
result[code_point] = fname
|
||||
|
|
|
@ -388,7 +388,7 @@ def authenticated_rest_api_view(is_webhook=False):
|
|||
if isinstance(profile, UserProfile):
|
||||
request._email = profile.email
|
||||
else:
|
||||
assert isinstance(profile, Deployment) # type: ignore # https://github.com/python/mypy/issues/1720#issuecomment-228596830
|
||||
assert isinstance(profile, Deployment)
|
||||
request._email = "deployment:" + role
|
||||
profile.rate_limits = ""
|
||||
# Apply rate limiting
|
||||
|
|
|
@ -30,5 +30,5 @@ def interactive_debug(sig, frame):
|
|||
# SIGUSR2 => Print stack + open interactive debugging shell
|
||||
def interactive_debug_listen():
|
||||
# type: () -> None
|
||||
signal.signal(signal.SIGUSR1, lambda sig, stack: traceback.print_stack(stack)) # type: ignore # https://github.com/python/typeshed/issues/294
|
||||
signal.signal(signal.SIGUSR1, lambda sig, stack: traceback.print_stack(stack))
|
||||
signal.signal(signal.SIGUSR2, interactive_debug)
|
||||
|
|
|
@ -323,7 +323,7 @@ def process_missed_message(to, message, pre_checked):
|
|||
def process_message(message, rcpt_to=None, pre_checked=False):
|
||||
# type: (message.Message, Optional[text_type], bool) -> None
|
||||
subject_header = message.get("Subject", "(no subject)")
|
||||
encoded_subject, encoding = decode_header(subject_header)[0] # type: ignore # https://github.com/python/typeshed/pull/333
|
||||
encoded_subject, encoding = decode_header(subject_header)[0]
|
||||
if encoding is None:
|
||||
subject = force_text(encoded_subject) # encoded_subject has type str when encoding is None
|
||||
else:
|
||||
|
|
|
@ -16,7 +16,7 @@ class NonClosingPool(sqlalchemy.pool.NullPool):
|
|||
|
||||
def recreate(self):
|
||||
# type: () -> NonClosingPool
|
||||
return self.__class__(creator=self._creator, # type: ignore # __class__
|
||||
return self.__class__(creator=self._creator,
|
||||
recycle=self._recycle,
|
||||
use_threadlocal=self._use_threadlocal,
|
||||
reset_on_return=self._reset_on_return,
|
||||
|
|
|
@ -133,5 +133,5 @@ def activity_averages_between(begin, end, by_day=True):
|
|||
return dict((str(day), calculate_stats(values, all_users=users_to_measure))
|
||||
for day, values in six.iteritems(seconds_active))
|
||||
else:
|
||||
return calculate_stats(list(chain.from_iterable(seconds_active.values())), # type: ignore # chain.from_iterable needs overload
|
||||
return calculate_stats(list(chain.from_iterable(seconds_active.values())),
|
||||
all_users=users_to_measure)
|
||||
|
|
|
@ -50,7 +50,7 @@ class TranslationTestCase(ZulipTestCase):
|
|||
]
|
||||
|
||||
for lang, word in languages:
|
||||
self.client.cookies = SimpleCookie({settings.LANGUAGE_COOKIE_NAME: lang}) # type: ignore # SimpleCookie has incomplete stubs in python 3
|
||||
self.client.cookies = SimpleCookie({settings.LANGUAGE_COOKIE_NAME: lang})
|
||||
|
||||
response = self.fetch('get', '/integrations/', 200)
|
||||
self.assert_in_response(word, response)
|
||||
|
|
|
@ -51,16 +51,16 @@ def convert_jira_markup(content, realm):
|
|||
|
||||
# Wrapping a block of code in {quote}stuff{quote} also block-quotes it
|
||||
quote_re = re.compile(r'{quote}(.*?){quote}', re.DOTALL)
|
||||
content = re.sub(quote_re, r'~~~ quote\n\1\n~~~', content) # type: ignore # https://github.com/python/typeshed/issues/160
|
||||
content = re.sub(quote_re, r'~~~ quote\n\1\n~~~', content)
|
||||
|
||||
# {noformat}stuff{noformat} blocks are just code blocks with no
|
||||
# syntax highlighting
|
||||
noformat_re = re.compile(r'{noformat}(.*?){noformat}', re.DOTALL)
|
||||
content = re.sub(noformat_re, r'~~~\n\1\n~~~', content) # type: ignore # https://github.com/python/typeshed/issues/160
|
||||
content = re.sub(noformat_re, r'~~~\n\1\n~~~', content)
|
||||
|
||||
# Code blocks are delineated by {code[: lang]} {code}
|
||||
code_re = re.compile(r'{code[^\n]*}(.*?){code}', re.DOTALL)
|
||||
content = re.sub(code_re, r'~~~\n\1\n~~~', content) # type: ignore # https://github.com/python/typeshed/issues/160
|
||||
content = re.sub(code_re, r'~~~\n\1\n~~~', content)
|
||||
|
||||
# Links are of form: [https://www.google.com] or [Link Title|https://www.google.com]
|
||||
# In order to support both forms, we don't match a | in bare links
|
||||
|
@ -68,7 +68,7 @@ def convert_jira_markup(content, realm):
|
|||
|
||||
# Full links which have a | are converted into a better markdown link
|
||||
full_link_re = re.compile(r'\[(?:(?P<title>[^|~]+)\|)(?P<url>.*)\]')
|
||||
content = re.sub(full_link_re, r'[\g<title>](\g<url>)', content) # type: ignore # https://github.com/python/typeshed/issues/160
|
||||
content = re.sub(full_link_re, r'[\g<title>](\g<url>)', content)
|
||||
|
||||
# Try to convert a JIRA user mention of format [~username] into a
|
||||
# Zulip user mention. We don't know the email, just the JIRA username,
|
||||
|
|
|
@ -350,7 +350,7 @@ class GitHubAuthBackend(SocialAuthMixin, GithubOAuth2):
|
|||
# type: (*Any, **Any) -> Optional[UserProfile]
|
||||
kwargs['return_data'] = {}
|
||||
|
||||
request = self.strategy.request # type: ignore # This comes from Python Social Auth.
|
||||
request = self.strategy.request
|
||||
kwargs['realm_subdomain'] = get_subdomain(request)
|
||||
|
||||
user_profile = None
|
||||
|
|
Loading…
Reference in New Issue