docs: Various cleanup of outdated comments and docstrings (#31754)
- Remove pylint warning suppression from SHAKE-128 hexdigest calls; these are no longer needed as of astroid 2.12.12. For background, see issue <https://github.com/PyCQA/pylint/issues/4039>. Also, correct a comment that referred to SHAKE-256 instead of SHAKE-128. - Replace "released" with "beta" in several places where there was a copy & paste error in dark_lang. Add mention of `beta_lang` to a docstring where it was omitted. - Remove comment regarding Mongo startup; the code it referred to has since been removed. - Fix typos.
This commit is contained in:
@@ -15,7 +15,7 @@ def fake_view(request):
|
||||
|
||||
|
||||
class TestEnsureCsrfCookieCrossDomain(TestCase):
|
||||
"""Test the `ensucre_csrf_cookie_cross_domain` decorator. """
|
||||
"""Test the `ensure_csrf_cookie_cross_domain` decorator. """
|
||||
|
||||
def test_ensure_csrf_cookie_cross_domain(self):
|
||||
request = mock.Mock()
|
||||
|
||||
@@ -76,7 +76,7 @@ class DarkLangMiddleware(MiddlewareMixin):
|
||||
@property
|
||||
def beta_langs(self):
|
||||
"""
|
||||
Current list of released languages
|
||||
Current list of beta languages
|
||||
"""
|
||||
language_options = DarkLangConfig.current().beta_languages_list
|
||||
if settings.LANGUAGE_CODE not in language_options:
|
||||
@@ -123,7 +123,7 @@ class DarkLangMiddleware(MiddlewareMixin):
|
||||
|
||||
def _clean_accept_headers(self, request):
|
||||
"""
|
||||
Remove any language that is not either in ``self.released_langs`` or
|
||||
Remove any language that is not either in ``self.released_langs`` or ``self.beta_langs`` (if enabled) or
|
||||
a territory of one of those languages.
|
||||
"""
|
||||
accept = request.META.get('HTTP_ACCEPT_LANGUAGE', None)
|
||||
|
||||
@@ -47,7 +47,7 @@ class DarkLangConfig(ConfigurationModel):
|
||||
@property
|
||||
def beta_languages_list(self):
|
||||
"""
|
||||
``released_languages`` as a list of language codes.
|
||||
``beta_languages`` as a list of language codes.
|
||||
|
||||
Example: ['it', 'de-at', 'es', 'pt-br']
|
||||
"""
|
||||
|
||||
@@ -141,7 +141,7 @@ def _get_user_by_email_or_username(request, api_version):
|
||||
user = _get_user_by_username(email_or_username)
|
||||
|
||||
if not user:
|
||||
digest = hashlib.shake_128(email_or_username.encode('utf-8')).hexdigest(16) # pylint: disable=too-many-function-args
|
||||
digest = hashlib.shake_128(email_or_username.encode('utf-8')).hexdigest(16)
|
||||
AUDIT_LOG.warning(f"Login failed - Unknown user email or username {digest}")
|
||||
|
||||
return user
|
||||
|
||||
@@ -337,7 +337,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin):
|
||||
|
||||
def test_login_fail_no_user_exists(self):
|
||||
nonexistent_email = 'not_a_user@edx.org'
|
||||
# pylint: disable=too-many-function-args
|
||||
email_hash = hashlib.shake_128(nonexistent_email.encode('utf-8')).hexdigest(16)
|
||||
response, mock_audit_log = self._login_response(
|
||||
nonexistent_email,
|
||||
@@ -442,7 +441,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin):
|
||||
the system does *not* send account activation email notification to the user.
|
||||
"""
|
||||
nonexistent_email = 'incorrect@email.com'
|
||||
# pylint: disable=too-many-function-args
|
||||
email_hash = hashlib.shake_128(nonexistent_email.encode('utf-8')).hexdigest(16)
|
||||
self.user.is_active = False
|
||||
self.user.save()
|
||||
@@ -454,7 +452,6 @@ class LoginTest(SiteMixin, CacheIsolationTestCase, OpenEdxEventsTestMixin):
|
||||
|
||||
def test_login_unicode_email(self):
|
||||
unicode_email = self.user_email + chr(40960)
|
||||
# pylint: disable=too-many-function-args
|
||||
email_hash = hashlib.shake_128(unicode_email.encode('utf-8')).hexdigest(16)
|
||||
response, mock_audit_log = self._login_response(
|
||||
unicode_email,
|
||||
|
||||
Reference in New Issue
Block a user