mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 02:23:57 +00:00
@@ -1,3 +1,3 @@
|
|||||||
six==1.10.0
|
six==1.10.0
|
||||||
mypy-lang==0.4.6
|
mypy==0.471
|
||||||
typed-ast==0.6.1
|
typed-ast==0.6.1
|
||||||
|
|||||||
@@ -93,7 +93,11 @@ if six.PY2 and os.path.exists(MYPY_VENV_PATH):
|
|||||||
else:
|
else:
|
||||||
mypy_command = "mypy"
|
mypy_command = "mypy"
|
||||||
|
|
||||||
extra_args = ["--fast-parser", "--silent-imports", "--check-untyped-defs", "--scripts-are-modules", "-i", "--cache-dir=var/mypy-cache"]
|
extra_args = ["--fast-parser",
|
||||||
|
"--silent-imports",
|
||||||
|
"--check-untyped-defs",
|
||||||
|
"--scripts-are-modules",
|
||||||
|
"-i", "--cache-dir=var/mypy-cache"]
|
||||||
if py_version == 2:
|
if py_version == 2:
|
||||||
extra_args.append("--py2")
|
extra_args.append("--py2")
|
||||||
if args.linecoverage_report:
|
if args.linecoverage_report:
|
||||||
|
|||||||
@@ -19,6 +19,6 @@ except IndexError:
|
|||||||
''')
|
''')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
p = pstats.Stats(fn)
|
p = pstats.Stats(fn) # type: ignore # stats stubs are broken
|
||||||
p.strip_dirs().sort_stats('cumulative').print_stats(25)
|
p.strip_dirs().sort_stats('cumulative').print_stats(25) # type: ignore # stats stubs are broken
|
||||||
p.strip_dirs().sort_stats('time').print_stats(25)
|
p.strip_dirs().sort_stats('time').print_stats(25) # type: ignore # stats stubs are broken
|
||||||
|
|||||||
@@ -640,7 +640,7 @@ def profiled(func):
|
|||||||
# type: (*Any, **Any) -> Any
|
# type: (*Any, **Any) -> Any
|
||||||
fn = func.__name__ + ".profile"
|
fn = func.__name__ + ".profile"
|
||||||
prof = cProfile.Profile()
|
prof = cProfile.Profile()
|
||||||
retval = prof.runcall(func, *args, **kwargs)
|
retval = prof.runcall(func, *args, **kwargs) # type: Any
|
||||||
prof.dump_stats(fn)
|
prof.dump_stats(fn)
|
||||||
return retval
|
return retval
|
||||||
return wrapped_func # type: ignore # https://github.com/python/mypy/issues/1927
|
return wrapped_func # type: ignore # https://github.com/python/mypy/issues/1927
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ from boto.s3.key import Key
|
|||||||
from boto.s3.connection import S3Connection
|
from boto.s3.connection import S3Connection
|
||||||
from mimetypes import guess_type, guess_extension
|
from mimetypes import guess_type, guess_extension
|
||||||
|
|
||||||
|
from zerver.lib.str_utils import force_bytes, force_str
|
||||||
from zerver.models import get_user_profile_by_email, get_user_profile_by_id
|
from zerver.models import get_user_profile_by_email, get_user_profile_by_id
|
||||||
from zerver.models import Attachment
|
from zerver.models import Attachment
|
||||||
from zerver.models import Realm, UserProfile, Message
|
from zerver.models import Realm, UserProfile, Message
|
||||||
@@ -152,7 +153,7 @@ def upload_image_to_s3(
|
|||||||
else:
|
else:
|
||||||
headers = None
|
headers = None
|
||||||
|
|
||||||
key.set_contents_from_string(contents, headers=headers)
|
key.set_contents_from_string(force_str(contents), headers=headers)
|
||||||
|
|
||||||
def get_file_info(request, user_file):
|
def get_file_info(request, user_file):
|
||||||
# type: (HttpRequest, File) -> Tuple[Text, Optional[Text]]
|
# type: (HttpRequest, File) -> Tuple[Text, Optional[Text]]
|
||||||
@@ -276,7 +277,7 @@ class S3UploadBackend(ZulipUploadBackend):
|
|||||||
conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)
|
conn = S3Connection(settings.S3_KEY, settings.S3_SECRET_KEY)
|
||||||
bucket = get_bucket(conn, bucket_name)
|
bucket = get_bucket(conn, bucket_name)
|
||||||
key = bucket.get_key(email_hash)
|
key = bucket.get_key(email_hash)
|
||||||
image_data = key.get_contents_as_string()
|
image_data = force_bytes(key.get_contents_as_string())
|
||||||
|
|
||||||
resized_medium = resize_avatar(image_data, MEDIUM_AVATAR_SIZE)
|
resized_medium = resize_avatar(image_data, MEDIUM_AVATAR_SIZE)
|
||||||
upload_image_to_s3(
|
upload_image_to_s3(
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ def environment(**options):
|
|||||||
'minified_js': minified_js,
|
'minified_js': minified_js,
|
||||||
})
|
})
|
||||||
|
|
||||||
env.install_gettext_translations(translation, True)
|
env.install_gettext_translations(translation, True) # type: ignore # https://github.com/python/typeshed/issues/927
|
||||||
|
|
||||||
env.filters['slugify'] = slugify
|
env.filters['slugify'] = slugify
|
||||||
env.filters['pluralize'] = pluralize
|
env.filters['pluralize'] = pluralize
|
||||||
|
|||||||
Reference in New Issue
Block a user