ruff: Fix UP035 Import from `collections.abc`, `typing` instead.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-07-11 17:30:25 -07:00 committed by Tim Abbott
parent 531b34cb4c
commit 0fa5e7f629
240 changed files with 460 additions and 332 deletions

View File

@ -1,13 +1,14 @@
import logging
import time
from collections import OrderedDict, defaultdict
from collections.abc import Callable, Sequence
from datetime import datetime, timedelta
from typing import Callable, Sequence, Union
from typing import TypeAlias, Union
from django.conf import settings
from django.db import connection, models
from psycopg2.sql import SQL, Composable, Identifier, Literal
from typing_extensions import TypeAlias, override
from typing_extensions import override
from analytics.models import (
BaseCount,

View File

@ -1,9 +1,10 @@
from collections.abc import Mapping
from datetime import timedelta
from typing import Any, Mapping
from typing import Any, TypeAlias
from django.core.files.uploadedfile import UploadedFile
from django.utils.timezone import now as timezone_now
from typing_extensions import TypeAlias, override
from typing_extensions import override
from analytics.lib.counts import COUNT_STATS, CountStat, do_drop_all_analytics_tables
from analytics.lib.fixtures import generate_time_series_data

View File

@ -1,6 +1,7 @@
from collections.abc import Iterator
from contextlib import AbstractContextManager, ExitStack, contextmanager
from datetime import datetime, timedelta, timezone
from typing import Any, Iterator
from typing import Any
from unittest import mock
import time_machine

View File

@ -1,7 +1,7 @@
import logging
from collections import defaultdict
from datetime import datetime, timedelta, timezone
from typing import Any, Optional, TypeVar, cast
from typing import Any, Optional, TypeAlias, TypeVar, cast
from django.conf import settings
from django.db.models import QuerySet
@ -10,7 +10,6 @@ from django.shortcuts import render
from django.utils import translation
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from typing_extensions import TypeAlias
from analytics.lib.counts import COUNT_STATS, CountStat
from analytics.lib.time_utils import time_range

View File

@ -3,8 +3,9 @@
__revision__ = "$Id: models.py 28 2009-10-22 15:03:02Z jarek.zgoda $"
import secrets
from base64 import b32encode
from collections.abc import Mapping
from datetime import timedelta
from typing import Mapping, Optional, Union, cast
from typing import Optional, TypeAlias, Union, cast
from urllib.parse import urljoin
from django.conf import settings
@ -16,7 +17,7 @@ from django.http import HttpRequest, HttpResponse
from django.template.response import TemplateResponse
from django.urls import reverse
from django.utils.timezone import now as timezone_now
from typing_extensions import TypeAlias, override
from typing_extensions import override
from confirmation import settings as confirmation_settings
from zerver.lib.types import UnspecifiedValue

View File

@ -1,8 +1,9 @@
from collections import defaultdict
from collections.abc import Callable, Sequence
from dataclasses import dataclass
from datetime import datetime
from decimal import Decimal
from typing import Any, Callable, Sequence
from typing import Any
from urllib.parse import urlencode
from django.conf import settings

View File

@ -1,12 +1,13 @@
from collections.abc import Callable
from functools import wraps
from typing import Callable
from typing import Concatenate
from urllib.parse import urlencode, urljoin
from django.conf import settings
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect, JsonResponse
from django.shortcuts import render
from django.urls import reverse
from typing_extensions import Concatenate, ParamSpec
from typing_extensions import ParamSpec
from corporate.lib.remote_billing_util import (
RemoteBillingIdentityExpiredError,

View File

@ -3,12 +3,13 @@ import math
import os
import secrets
from abc import ABC, abstractmethod
from collections.abc import Callable, Generator
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from decimal import Decimal
from enum import Enum
from functools import wraps
from typing import Any, Callable, Generator, Literal, TypedDict, TypeVar
from typing import Any, Literal, TypedDict, TypeVar
from urllib.parse import urlencode, urljoin
import stripe

View File

@ -1,5 +1,6 @@
import logging
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import stripe
from django.conf import settings

View File

@ -6,11 +6,12 @@ import re
import sys
import typing
import uuid
from collections.abc import Callable, Mapping, Sequence
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
from decimal import Decimal
from functools import wraps
from typing import TYPE_CHECKING, Any, Callable, Literal, Mapping, Optional, Sequence, TypeVar, cast
from typing import TYPE_CHECKING, Any, Literal, Optional, TypeVar, cast
from unittest import mock
from unittest.mock import MagicMock, Mock, patch

View File

@ -1,12 +1,11 @@
import logging
from typing import Any, Literal
from typing import Annotated, Any, Literal
from django.http import HttpRequest, HttpResponse, HttpResponseNotAllowed, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
from django.utils.translation import gettext as _
from pydantic import AfterValidator, Json
from typing_extensions import Annotated
from corporate.lib.decorator import (
authenticated_remote_realm_management_endpoint,

View File

@ -1,8 +1,9 @@
import itertools
import re
from collections.abc import Collection
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Collection
from typing import Any
from django.db.models import QuerySet
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound

View File

@ -1,5 +1,5 @@
import logging
from typing import Any, Literal, cast
from typing import Any, Literal, TypeAlias, cast
from urllib.parse import urlsplit, urlunsplit
from django.conf import settings
@ -15,7 +15,6 @@ from django.utils.translation import get_language
from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt
from pydantic import Json
from typing_extensions import TypeAlias
from confirmation.models import (
Confirmation,

View File

@ -1,9 +1,10 @@
import uuid
from collections.abc import Iterable
from contextlib import suppress
from dataclasses import dataclass
from datetime import timedelta
from operator import attrgetter
from typing import Any, Iterable
from typing import Annotated, Any, Literal
from urllib.parse import urlencode, urlsplit
from django import forms
@ -18,7 +19,6 @@ from django.utils.timesince import timesince
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from pydantic import AfterValidator, Json, NonNegativeInt
from typing_extensions import Annotated, Literal
from confirmation.models import Confirmation, confirmation_url
from confirmation.settings import STATUS_USED

View File

@ -1,10 +1,10 @@
import logging
from typing import Annotated
from django.conf import settings
from django.http import HttpRequest, HttpResponse, HttpResponseRedirect
from django.shortcuts import render
from pydantic import AfterValidator, Json
from typing_extensions import Annotated
from corporate.lib.decorator import (
authenticated_remote_realm_management_endpoint,

View File

@ -3,7 +3,8 @@
import contextlib
import sys
import time
from typing import Any, Iterable, Sequence
from collections.abc import Iterable, Sequence
from typing import Any
sys.path.append("/home/zulip/deployments/current")
from scripts.lib.setup_path import setup_path

View File

@ -7,9 +7,10 @@ import os
import subprocess
import sys
from collections import defaultdict
from collections.abc import Mapping
from datetime import datetime, timedelta, timezone
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Mapping, Protocol
from typing import Protocol
from urllib.parse import parse_qs, urlsplit

View File

@ -4,7 +4,7 @@ import hashlib
import os
import subprocess
import sys
from typing import Iterable
from collections.abc import Iterable
def expand_reqs_helper(fpath: str) -> list[str]:

View File

@ -15,8 +15,9 @@ import subprocess
import sys
import time
import uuid
from collections.abc import Sequence
from datetime import datetime, timedelta
from typing import IO, Any, Literal, Sequence, overload
from typing import IO, Any, Literal, overload
from urllib.parse import SplitResult
import zoneinfo

View File

@ -10,7 +10,8 @@ import signal
import sys
from datetime import date, datetime, timedelta, timezone
from enum import Enum, auto
from typing import Match, TextIO
from re import Match
from typing import TextIO
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(ZULIP_PATH)

View File

@ -14,7 +14,8 @@ import difflib
import os
import subprocess
import sys
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import orjson

View File

@ -11,7 +11,7 @@ from tools.lib import sanity_check
sanity_check.check_venv(__file__)
from typing import Iterable
from collections.abc import Iterable
from zulint import lister

View File

@ -4,7 +4,7 @@ import platform
import shlex
import subprocess
import sys
from typing import Callable
from collections.abc import Callable
TOOLS_DIR = os.path.dirname(__file__)
ROOT_DIR = os.path.dirname(TOOLS_DIR)

View File

@ -1,7 +1,7 @@
import json
import os
import re
from typing import Callable, Iterator
from collections.abc import Callable, Iterator
from urllib.parse import urlsplit
import scrapy

View File

@ -1,5 +1,5 @@
import re
from typing import Match
from re import Match
from bs4 import BeautifulSoup

View File

@ -1,4 +1,4 @@
from typing import Callable
from collections.abc import Callable
from typing_extensions import override

View File

@ -3,7 +3,7 @@ import os
import subprocess
import sys
from argparse import ArgumentParser
from typing import Iterable
from collections.abc import Iterable
from scripts.lib.zulip_tools import get_dev_uuid_var_path
from version import PROVISION_VERSION

View File

@ -2,8 +2,8 @@ import os
import subprocess
import sys
import time
from collections.abc import Iterator
from contextlib import ExitStack, contextmanager
from typing import Iterator
# Verify the Zulip venv is available.
from tools.lib import sanity_check

View File

@ -279,10 +279,10 @@ rules:
def $F(..., invalid_param: typing.Optional[<... zerver.lib.typed_endpoint.ApiParamConfig(...) ...>], ...) -> ...:
...
- pattern-not: |
def $F(..., $A: typing_extensions.Annotated[<... zerver.lib.typed_endpoint.ApiParamConfig(...) ...>], ...) -> ...:
def $F(..., $A: typing.Annotated[<... zerver.lib.typed_endpoint.ApiParamConfig(...) ...>], ...) -> ...:
...
- pattern-not: |
def $F(..., $A: typing_extensions.Annotated[<... zerver.lib.typed_endpoint.ApiParamConfig(...) ...>] = ..., ...) -> ...:
def $F(..., $A: typing.Annotated[<... zerver.lib.typed_endpoint.ApiParamConfig(...) ...>] = ..., ...) -> ...:
...
- pattern-either:
- pattern: |

View File

@ -5,7 +5,8 @@
import os
import shutil
import sys
from typing import Any, Iterator, Sequence
from collections.abc import Iterator, Sequence
from typing import Any
import orjson

View File

@ -12,8 +12,9 @@ setup_path()
os.environ["DJANGO_SETTINGS_MODULE"] = "zproject.settings"
import argparse
import secrets
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Iterator, TypedDict
from typing import TypedDict
import boto3.session
import orjson

View File

@ -8,7 +8,8 @@ import shlex
import subprocess
import sys
import tempfile
from typing import TYPE_CHECKING, Iterator, cast
from collections.abc import Iterator
from typing import TYPE_CHECKING, cast
from unittest import mock
if TYPE_CHECKING:

View File

@ -3,7 +3,7 @@ import argparse
import os
import subprocess
import sys
from typing import Sequence
from collections.abc import Sequence
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.chdir(ZULIP_PATH)

View File

@ -4,7 +4,7 @@ import contextlib
import os
import subprocess
import sys
from typing import Iterator
from collections.abc import Iterator
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
os.chdir(ZULIP_PATH)

View File

@ -39,7 +39,7 @@ from tools.lib import sanity_check
sanity_check.check_venv(__file__)
from typing import Iterable
from collections.abc import Iterable
from tools.lib.test_script import (
add_provision_check_override_param,

View File

@ -1,4 +1,4 @@
from typing import Iterable, Sequence
from collections.abc import Iterable, Sequence
from zerver.lib.alert_words import add_user_alert_words, remove_user_alert_words
from zerver.models import UserProfile

View File

@ -1,6 +1,7 @@
from collections import defaultdict
from collections.abc import Iterable, Sequence
from datetime import timedelta
from typing import Any, Iterable, Sequence
from typing import Any
from django.conf import settings
from django.db import transaction

View File

@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable
import orjson
from django.db import transaction

View File

@ -1,4 +1,5 @@
from typing import Any, Iterable
from collections.abc import Iterable
from typing import Any
from django.db import transaction
from django.utils.translation import gettext as _

View File

@ -1,6 +1,7 @@
import logging
from collections.abc import Collection, Sequence
from datetime import datetime, timedelta
from typing import Any, Collection, Sequence
from typing import Any
from django.conf import settings
from django.contrib.contenttypes.models import ContentType

View File

@ -1,4 +1,5 @@
from typing import Iterable, TypedDict
from collections.abc import Iterable
from typing import TypedDict
from zerver.lib import retention
from zerver.lib.retention import move_messages_to_archive

View File

@ -1,7 +1,9 @@
import itertools
from collections import defaultdict
from collections.abc import Iterable
from collections.abc import Set as AbstractSet
from datetime import timedelta
from typing import AbstractSet, Any, Iterable
from typing import Any
from django.conf import settings
from django.db import transaction

View File

@ -1,9 +1,11 @@
import logging
from collections import defaultdict
from collections.abc import Callable, Collection, Sequence
from collections.abc import Set as AbstractSet
from dataclasses import dataclass
from datetime import timedelta
from email.headerregistry import Address
from typing import AbstractSet, Any, Callable, Collection, Sequence, TypedDict
from typing import Any, TypedDict
import orjson
from django.conf import settings

View File

@ -1,6 +1,6 @@
import logging
from collections.abc import Sequence
from datetime import datetime, timedelta
from typing import Sequence
from django.conf import settings
from django.db import transaction

View File

@ -1,6 +1,7 @@
import hashlib
from collections import defaultdict
from typing import Any, Collection, Iterable, Mapping
from collections.abc import Collection, Iterable, Mapping
from typing import Any, TypeAlias
from django.conf import settings
from django.db import transaction
@ -9,7 +10,6 @@ from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import override as override_language
from django_stubs_ext import ValuesQuerySet
from typing_extensions import TypeAlias
from zerver.actions.default_streams import (
do_remove_default_stream,

View File

@ -1,5 +1,6 @@
from collections.abc import Mapping, Sequence
from datetime import datetime
from typing import Mapping, Sequence, TypedDict
from typing import TypedDict
import django.db.utils
from django.db import transaction

View File

@ -1,5 +1,5 @@
from collections.abc import Iterable
from datetime import timedelta
from typing import Iterable
from django.conf import settings
from django.db import transaction

View File

@ -1,4 +1,5 @@
from typing import Any, Mapping
from collections.abc import Mapping
from typing import Any
from urllib.parse import urljoin
from django.conf import settings

View File

@ -3,14 +3,15 @@ import os
import random
import shutil
from collections import defaultdict
from collections.abc import Callable, Iterable, Iterator, Mapping
from collections.abc import Set as AbstractSet
from concurrent.futures import ProcessPoolExecutor, as_completed
from typing import AbstractSet, Any, Callable, Iterable, Iterator, Mapping, Protocol, TypeVar
from typing import Any, Protocol, TypeAlias, TypeVar
import orjson
import requests
from django.forms.models import model_to_dict
from django.utils.timezone import now as timezone_now
from typing_extensions import TypeAlias
from zerver.data_import.sequencer import NEXT_ID
from zerver.lib.avatar_hash import user_avatar_base_path_from_ids

View File

@ -10,7 +10,8 @@ import re
import secrets
import shutil
import subprocess
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
import orjson
from django.conf import settings

View File

@ -1,4 +1,5 @@
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
"""
This module helps you set up a bunch

View File

@ -7,9 +7,10 @@ import secrets
import shutil
import zipfile
from collections import defaultdict
from collections.abc import Iterator
from datetime import datetime, timezone
from email.headerregistry import Address
from typing import Any, Iterator, TypeVar
from typing import Any, TypeAlias, TypeVar
from urllib.parse import urlsplit
import orjson
@ -17,7 +18,6 @@ import requests
from django.conf import settings
from django.forms.models import model_to_dict
from django.utils.timezone import now as timezone_now
from typing_extensions import TypeAlias
from zerver.data_import.import_util import (
ZerverFieldsT,

View File

@ -1,7 +1,5 @@
import re
from typing import Any
from typing_extensions import TypeAlias
from typing import Any, TypeAlias
# stubs
ZerverFieldsT: TypeAlias = dict[str, Any]

View File

@ -1,9 +1,10 @@
import base64
import logging
from collections.abc import Callable, Sequence
from datetime import datetime
from functools import wraps
from io import BytesIO
from typing import TYPE_CHECKING, Callable, Sequence, TypeVar, cast, overload
from typing import TYPE_CHECKING, Concatenate, TypeVar, cast, overload
from urllib.parse import urlsplit
import django_otp
@ -23,7 +24,7 @@ from django.utils.translation import gettext as _
from django.views.decorators.csrf import csrf_exempt
from django_otp import user_has_device
from two_factor.utils import default_device
from typing_extensions import Concatenate, ParamSpec
from typing_extensions import ParamSpec
from zerver.context_processors import get_valid_realm_from_request
from zerver.lib.exceptions import (

View File

@ -1,4 +1,5 @@
from typing import Iterable, Sequence, cast
from collections.abc import Iterable, Sequence
from typing import cast
from django.utils.translation import gettext as _

View File

@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable
import ahocorasick
from django.db import transaction

View File

@ -1,6 +1,7 @@
import importlib
import json
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from django.conf import settings
from django.utils.translation import gettext as _

View File

@ -1,4 +1,5 @@
from typing import Any, Collection, Iterable
from collections.abc import Collection, Iterable
from typing import Any
from django.db.models import Model, QuerySet
from django.utils.timezone import now as timezone_now

View File

@ -7,8 +7,9 @@ import secrets
import sys
import time
import traceback
from collections.abc import Callable, Iterable, Sequence
from functools import _lru_cache_wrapper, lru_cache, wraps
from typing import TYPE_CHECKING, Any, Callable, Generic, Iterable, Sequence, TypeVar
from typing import TYPE_CHECKING, Any, Generic, TypeVar
from django.conf import settings
from django.core.cache import caches

View File

@ -1,7 +1,8 @@
# See https://zulip.readthedocs.io/en/latest/subsystems/caching.html for docs
import logging
from collections.abc import Callable, Iterable
from datetime import timedelta
from typing import Any, Callable, Iterable
from typing import Any
from django.conf import settings
from django.contrib.sessions.models import Session

View File

@ -3,8 +3,9 @@ Context managers, i.e. things you can use with the 'with' statement.
"""
import fcntl
from collections.abc import Iterator
from contextlib import contextmanager
from typing import IO, Any, Iterator
from typing import IO, Any
@contextmanager

View File

@ -9,9 +9,10 @@ the level of detail we desire or do comparison with OpenAPI types
easily with the native Python type system.
"""
from collections.abc import Callable, Sequence
from contextlib import suppress
from dataclasses import dataclass
from typing import Any, Callable, Sequence
from typing import Any
from django.core.exceptions import ValidationError
from django.core.validators import URLValidator

View File

@ -1,9 +1,10 @@
import time
from typing import Any, Callable, Iterable, Mapping, Sequence, TypeVar
from collections.abc import Callable, Iterable, Mapping, Sequence
from typing import Any, TypeAlias, TypeVar
from psycopg2.extensions import connection, cursor
from psycopg2.sql import Composable
from typing_extensions import TypeAlias, override
from typing_extensions import override
CursorObj = TypeVar("CursorObj", bound=cursor)
Query: TypeAlias = str | bytes | Composable

View File

@ -2,15 +2,15 @@ import functools
import heapq
import logging
from collections import defaultdict
from collections.abc import Collection, Iterator
from datetime import datetime, timedelta, timezone
from typing import Any, Collection, Iterator
from typing import Any, TypeAlias
from django.conf import settings
from django.db import transaction
from django.db.models import Exists, OuterRef, QuerySet
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from typing_extensions import TypeAlias
from confirmation.models import one_click_unsubscribe_link
from zerver.context_processors import common_context

View File

@ -1,12 +1,13 @@
import time
from collections.abc import Callable
from functools import wraps
from typing import Any, Callable, Literal
from typing import Annotated, Any, Concatenate, Literal
from django.core.exceptions import ValidationError
from django.http import HttpRequest, HttpResponse
from django.utils.translation import gettext as _
from pydantic import BaseModel, ConfigDict
from typing_extensions import Annotated, Concatenate, ParamSpec
from typing_extensions import ParamSpec
from zerver.lib.addressee import get_user_profiles_by_ids
from zerver.lib.exceptions import JsonableError, ResourceNotFoundError

View File

@ -3,7 +3,7 @@ import re
import secrets
from email.headerregistry import Address, AddressHeader
from email.message import EmailMessage
from typing import Match
from re import Match
from django.conf import settings
from django.utils.translation import gettext as _

View File

@ -1,5 +1,6 @@
import re
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from django.conf import settings
from django.utils.text import slugify

View File

@ -1,6 +1,6 @@
from collections.abc import Callable
from email.errors import HeaderParseError
from email.headerregistry import Address
from typing import Callable
from django.core import validators
from django.core.exceptions import ValidationError

View File

@ -27,7 +27,7 @@
# See check_delete_message and check_presence for examples of this
# paradigm.
from typing import Sequence
from collections.abc import Sequence
from zerver.lib.data_types import (
DictType,

View File

@ -3,7 +3,8 @@
import copy
import logging
import time
from typing import Any, Callable, Collection, Iterable, Mapping, Sequence
from collections.abc import Callable, Collection, Iterable, Mapping, Sequence
from typing import Any
from django.conf import settings
from django.utils.translation import gettext as _

View File

@ -12,10 +12,11 @@ import os
import shutil
import subprocess
import tempfile
from collections.abc import Callable, Iterable, Mapping
from contextlib import suppress
from datetime import datetime
from functools import cache
from typing import Any, Callable, Iterable, Mapping, Optional, TypedDict
from typing import Any, Optional, TypeAlias, TypedDict
import orjson
from django.apps import apps
@ -24,7 +25,6 @@ from django.db.models import Exists, OuterRef, Q
from django.forms.models import model_to_dict
from django.utils.timezone import is_naive as timezone_is_naive
from mypy_boto3_s3.service_resource import Object
from typing_extensions import TypeAlias
import zerver.lib.upload
from analytics.models import RealmCount, StreamCount, UserCount

View File

@ -1,6 +1,7 @@
import logging
import time
from typing import Callable, TypeVar
from collections.abc import Callable
from typing import TypeVar
from django.db import connection
from django.db.backends.utils import CursorWrapper

View File

@ -1,4 +1,4 @@
from typing import Mapping
from collections.abc import Mapping
from bs4 import BeautifulSoup
from django.utils.html import escape

View File

@ -1,13 +1,13 @@
import os
from collections.abc import Callable, Sequence
from dataclasses import dataclass, field
from typing import Any, Callable, Sequence
from typing import Any, TypeAlias
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import URLResolver, path
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy
from django_stubs_ext import StrPromise
from typing_extensions import TypeAlias
from zerver.lib.storage import static_path

View File

@ -7,10 +7,12 @@ import mimetypes
import re
import time
from collections import deque
from collections.abc import Callable
from dataclasses import dataclass
from datetime import datetime, timezone
from functools import lru_cache
from typing import Any, Callable, Generic, Match, Optional, Pattern, TypedDict, TypeVar, cast
from re import Match, Pattern
from typing import Any, Generic, Optional, TypeAlias, TypedDict, TypeVar, cast
from urllib.parse import parse_qs, quote, urlencode, urljoin, urlsplit, urlunsplit
from xml.etree.ElementTree import Element, SubElement
@ -34,7 +36,7 @@ from django.conf import settings
from markdown.blockparser import BlockParser
from markdown.extensions import codehilite, nl2br, sane_lists, tables
from tlds import tld_set
from typing_extensions import Self, TypeAlias, override
from typing_extensions import Self, override
from zerver.lib import mention
from zerver.lib.cache import cache_with_key

View File

@ -1,6 +1,7 @@
import json
import re
from typing import Any, Mapping, Sequence
from collections.abc import Mapping, Sequence
from typing import Any
import markdown
from django.utils.html import escape as escape_html

View File

@ -2,8 +2,9 @@ import copy
import json
import re
from collections import OrderedDict
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, Mapping
from typing import Any
import markdown
from markdown.extensions import Extension

View File

@ -77,7 +77,8 @@ Dependencies:
"""
import re
from typing import Any, Callable, Iterable, Mapping, MutableSequence, Sequence
from collections.abc import Callable, Iterable, Mapping, MutableSequence, Sequence
from typing import Any
import lxml.html
from django.utils.html import escape

View File

@ -1,5 +1,6 @@
import re
from typing import Any, Match
from re import Match
from typing import Any
from markdown import Markdown
from markdown.extensions import Extension

View File

@ -1,5 +1,6 @@
import re
from typing import Any, Match
from re import Match
from typing import Any
from markdown import Markdown
from markdown.extensions import Extension

View File

@ -1,5 +1,6 @@
import re
from typing import Any, Match
from re import Match
from typing import Any
from markdown import Markdown
from markdown.extensions import Extension

View File

@ -1,6 +1,6 @@
import os
import re
from typing import Match
from re import Match
from xml.etree.ElementTree import Element
from markdown import Extension, Markdown

View File

@ -1,4 +1,5 @@
from typing import Any, Mapping
from collections.abc import Mapping
from typing import Any
from xml.etree.ElementTree import Element, SubElement
import markdown

View File

@ -1,5 +1,6 @@
import re
from typing import Any, Mapping
from collections.abc import Mapping
from typing import Any
import markdown
from markdown.extensions import Extension

View File

@ -1,7 +1,7 @@
import functools
import re
from dataclasses import dataclass
from typing import Match
from re import Match
from django.conf import settings
from django.db.models import Q

View File

@ -1,7 +1,8 @@
import re
from collections.abc import Callable, Collection, Mapping, Sequence
from dataclasses import dataclass, field
from datetime import datetime, timedelta
from typing import Any, Callable, Collection, Mapping, Sequence, TypedDict
from typing import Any, TypedDict
from django.conf import settings
from django.db import connection

View File

@ -1,8 +1,9 @@
import copy
import zlib
from collections.abc import Iterable
from datetime import datetime
from email.headerregistry import Address
from typing import Any, Iterable, TypedDict
from typing import Any, TypedDict
import orjson

View File

@ -1,5 +1,6 @@
import time
from typing import Any, Callable
from collections.abc import Callable
from typing import Any
from django.db import connection
from django.db.backends.base.schema import BaseDatabaseSchemaEditor

View File

@ -1,6 +1,7 @@
import re
from collections.abc import Callable, Iterable, Sequence
from dataclasses import dataclass
from typing import Any, Callable, Generic, Iterable, Sequence, TypeVar
from typing import Any, Generic, TypeAlias, TypeVar
from django.conf import settings
from django.contrib.auth.models import AnonymousUser
@ -29,7 +30,7 @@ from sqlalchemy.sql import (
)
from sqlalchemy.sql.selectable import SelectBase
from sqlalchemy.types import ARRAY, Boolean, Integer, Text
from typing_extensions import TypeAlias, override
from typing_extensions import override
from zerver.lib.addressee import get_user_profiles, get_user_profiles_by_ids
from zerver.lib.exceptions import ErrorCode, JsonableError, MissingAuthenticationError

View File

@ -19,8 +19,8 @@ from users:
"""
import os
from collections.abc import Collection, Sequence
from dataclasses import dataclass
from typing import Collection, Sequence
from django.conf import settings

View File

@ -1,4 +1,5 @@
from typing import Any, Collection, Protocol
from collections.abc import Collection
from typing import Any, Protocol
from django.utils.translation import gettext as _

View File

@ -1,6 +1,7 @@
import weakref
from abc import ABCMeta, abstractmethod
from typing import Any, ClassVar, Generic, MutableMapping, TypeVar
from collections.abc import MutableMapping
from typing import Any, ClassVar, Generic, TypeVar
from typing_extensions import override

View File

@ -1,6 +1,7 @@
import math
from collections.abc import Collection
from dataclasses import dataclass
from typing import Any, Collection
from typing import Any
from zerver.lib.mention import MentionData
from zerver.lib.user_groups import get_user_group_member_ids

View File

@ -1,10 +1,13 @@
# Workaround for missing functools.partial support in mypy
# (https://github.com/python/mypy/issues/1484).
from typing import TYPE_CHECKING, Callable, TypeVar, overload
from collections.abc import Callable
from typing import TYPE_CHECKING, TypeVar, overload
if TYPE_CHECKING:
from typing_extensions import Concatenate, ParamSpec
from typing import Concatenate
from typing_extensions import ParamSpec
P = ParamSpec("P")
T1 = TypeVar("T1")

View File

@ -1,4 +1,5 @@
from typing import Any, Callable, TypeVar
from collections.abc import Callable
from typing import Any, TypeVar
ReturnT = TypeVar("ReturnT")

View File

@ -1,7 +1,8 @@
import time
from collections import defaultdict
from collections.abc import Mapping, Sequence
from datetime import datetime, timedelta
from typing import Any, Mapping, Sequence
from typing import Any
from django.conf import settings
from django.utils.timezone import now as timezone_now

View File

@ -1,6 +1,7 @@
import cProfile
from collections.abc import Callable
from functools import wraps
from typing import Callable, TypeVar
from typing import TypeVar
from typing_extensions import ParamSpec

View File

@ -5,10 +5,11 @@ import base64
import copy
import logging
import re
from collections.abc import Iterable, Mapping, Sequence
from dataclasses import dataclass
from email.headerregistry import Address
from functools import cache
from typing import TYPE_CHECKING, Any, Iterable, Mapping, Optional, Sequence, Union
from typing import TYPE_CHECKING, Any, Optional, TypeAlias, Union
import lxml.html
import orjson
@ -24,7 +25,7 @@ from firebase_admin import exceptions as firebase_exceptions
from firebase_admin import initialize_app as firebase_initialize_app
from firebase_admin import messaging as firebase_messaging
from firebase_admin.messaging import UnregisteredError as FCMUnregisteredError
from typing_extensions import TypeAlias, override
from typing_extensions import override
from analytics.lib.counts import COUNT_STATS, do_increment_logging_stat
from zerver.actions.realm_settings import (

View File

@ -5,7 +5,8 @@ import threading
import time
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from typing import Any, Callable, Generic, Mapping, TypeVar
from collections.abc import Callable, Mapping
from typing import Any, Generic, TypeAlias, TypeVar
import orjson
import pika
@ -18,7 +19,7 @@ from pika.adapters.blocking_connection import BlockingChannel
from pika.channel import Channel
from pika.spec import Basic
from tornado import ioloop
from typing_extensions import TypeAlias, override
from typing_extensions import override
from zerver.lib.utils import assert_is_not_none

View File

@ -1,4 +1,4 @@
from typing import Sequence
from collections.abc import Sequence
from django.core.exceptions import ValidationError
from django.utils.translation import gettext as _

Some files were not shown because too many files have changed in this diff Show More