mirror of https://github.com/zulip/zulip.git
thumbor: Replace comment type annotations with normal annotations.
Run custom lint checks on thumbor files.
This commit is contained in:
parent
a486872a8e
commit
261bc043c9
|
@ -329,10 +329,6 @@ python_rules = RuleList(
|
||||||
'good_lines': ['if my_django_model.id == 42', 'self.user_profile._meta.pk'],
|
'good_lines': ['if my_django_model.id == 42', 'self.user_profile._meta.pk'],
|
||||||
'bad_lines': ['if my_django_model.pk == 42']},
|
'bad_lines': ['if my_django_model.pk == 42']},
|
||||||
{'pattern': r'^\s*#\s*type:',
|
{'pattern': r'^\s*#\s*type:',
|
||||||
'exclude': {
|
|
||||||
# thumbor is (currently) python2 only
|
|
||||||
'zthumbor/',
|
|
||||||
},
|
|
||||||
'description': 'Comment-style function type annotation. Use Python3 style annotations instead.',
|
'description': 'Comment-style function type annotation. Use Python3 style annotations instead.',
|
||||||
},
|
},
|
||||||
{'pattern': r"\S\s*#\s*type:(?!\s*ignore)",
|
{'pattern': r"\S\s*#\s*type:(?!\s*ignore)",
|
||||||
|
|
|
@ -28,8 +28,9 @@ if PRODUCTION:
|
||||||
else:
|
else:
|
||||||
secrets_file.read(os.path.join(DEPLOY_ROOT, "zproject/dev-secrets.conf"))
|
secrets_file.read(os.path.join(DEPLOY_ROOT, "zproject/dev-secrets.conf"))
|
||||||
|
|
||||||
def get_secret(key, default_value=None, development_only=False):
|
def get_secret(
|
||||||
# type: (str, Optional[Any], bool) -> Optional[Any]
|
key: str, default_value: Optional[Any] = None, development_only: bool = False,
|
||||||
|
) -> Optional[Any]:
|
||||||
if development_only and PRODUCTION:
|
if development_only and PRODUCTION:
|
||||||
return default_value
|
return default_value
|
||||||
if secrets_file.has_option('secrets', key):
|
if secrets_file.has_option('secrets', key):
|
||||||
|
@ -40,8 +41,7 @@ THUMBOR_EXTERNAL_TYPE = 'external'
|
||||||
THUMBOR_S3_TYPE = 's3'
|
THUMBOR_S3_TYPE = 's3'
|
||||||
THUMBOR_LOCAL_FILE_TYPE = 'local_file'
|
THUMBOR_LOCAL_FILE_TYPE = 'local_file'
|
||||||
|
|
||||||
def separate_url_and_source_type(url):
|
def separate_url_and_source_type(url: Text) -> Tuple[Text, Text]:
|
||||||
# type: (Text) -> Tuple[Text, Text]
|
|
||||||
THUMBNAIL_URL_PATT = re.compile('^(?P<actual_url>.+)/source_type/(?P<source_type>.+)')
|
THUMBNAIL_URL_PATT = re.compile('^(?P<actual_url>.+)/source_type/(?P<source_type>.+)')
|
||||||
matches = THUMBNAIL_URL_PATT.match(url)
|
matches = THUMBNAIL_URL_PATT.match(url)
|
||||||
assert matches is not None
|
assert matches is not None
|
||||||
|
|
|
@ -17,15 +17,13 @@ from .helpers import (
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def get_not_found_result():
|
def get_not_found_result() -> LoaderResult:
|
||||||
# type: () -> LoaderResult
|
|
||||||
result = LoaderResult()
|
result = LoaderResult()
|
||||||
result.error = LoaderResult.ERROR_NOT_FOUND
|
result.error = LoaderResult.ERROR_NOT_FOUND
|
||||||
result.successful = False
|
result.successful = False
|
||||||
return result
|
return result
|
||||||
|
|
||||||
async def load(context, url):
|
async def load(context: Context, url: str) -> LoaderResult:
|
||||||
# type: (Context, str) -> LoaderResult
|
|
||||||
source_type, encoded_url = separate_url_and_source_type(url)
|
source_type, encoded_url = separate_url_and_source_type(url)
|
||||||
actual_url = base64.urlsafe_b64decode(urllib.parse.unquote(encoded_url)).decode('utf-8')
|
actual_url = base64.urlsafe_b64decode(urllib.parse.unquote(encoded_url)).decode('utf-8')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue