Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump black from 19.10b0 to 20.8b1 #2060

Merged
merged 2 commits into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def upgrade():

op.create_table(
"course_groups_exported_from_h",
sa.Column("authority_provided_id", sa.UnicodeText(), primary_key=True,),
sa.Column("authority_provided_id", sa.UnicodeText(), primary_key=True),
sa.Column("created", sa.DateTime(), nullable=False),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@


def upgrade():
op.add_column(
"group_info", sa.Column("info", MutableDict.as_mutable(JSONB)),
)
op.add_column("group_info", sa.Column("info", MutableDict.as_mutable(JSONB)))
group_info_table = sa.table(
"group_info", sa.Column("info", MutableDict.as_mutable(JSONB))
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def upgrade():

session.add(
CourseGroupsExportedFromH(
authority_provided_id=authority_provided_id, created=created,
authority_provided_id=authority_provided_id, created=created
)
)
rows_inserted += 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

def upgrade():
op.add_column(
"application_instances", sa.Column("settings", MutableDict.as_mutable(JSONB)),
"application_instances", sa.Column("settings", MutableDict.as_mutable(JSONB))
)


Expand Down
2 changes: 1 addition & 1 deletion lms/models/application_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_by_consumer_key(cls, db, consumer_key):

@classmethod
def build_from_lms_url( # pylint:disable=too-many-arguments
cls, lms_url, email, developer_key, developer_secret, encryption_key, settings,
cls, lms_url, email, developer_key, developer_secret, encryption_key, settings
):
"""Instantiate ApplicationInstance with lms_url."""
encrypted_secret = developer_secret
Expand Down
2 changes: 1 addition & 1 deletion lms/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def includeme(config):
"lms.services.launch_verifier.LaunchVerifier", name="launch_verifier"
)
config.register_service_factory(
"lms.services.grading_info.GradingInfoService", name="grading_info",
"lms.services.grading_info.GradingInfoService", name="grading_info"
)
config.register_service_factory(
"lms.services.lti_outcomes.LTIOutcomesClient", name="lti_outcomes_client"
Expand Down
4 changes: 1 addition & 3 deletions lms/services/lti_outcomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ def read_result(self, lis_result_sourcedid):
except (TypeError, KeyError, ValueError):
return None

def record_result(
self, lis_result_sourcedid, score=None, pre_record_hook=None,
):
def record_result(self, lis_result_sourcedid, score=None, pre_record_hook=None):
"""
Set the score or content URL for a student submission to an assignment.

Expand Down
2 changes: 1 addition & 1 deletion lms/views/basic_lti_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def sync_lti_data_to_h(self):
"""

self.request.find_service(name="lti_h").sync(
[self.context.h_group], self.request.params,
[self.context.h_group], self.request.params
)

def store_lti_data(self):
Expand Down
2 changes: 1 addition & 1 deletion lms/views/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def forbidden(_exc, request):


@exception_view_config(
context=httpexceptions.HTTPClientError, renderer=DEFAULT_RENDERER,
context=httpexceptions.HTTPClientError, renderer=DEFAULT_RENDERER
)
def http_client_error(exc, request):
"""Handle an HTTP 4xx (client error) exception."""
Expand Down
6 changes: 4 additions & 2 deletions requirements/format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
# pip-compile requirements/format.in
#
appdirs==1.4.4 # via black
attrs==20.1.0 # via black
black==19.10b0 # via -r requirements/format.in
black==20.8b1 # via -r requirements/format.in
click==7.1.2 # via black
dataclasses==0.7 # via black
isort==5.4.2 # via -r requirements/format.in
mypy-extensions==0.4.3 # via black
pathspec==0.8.0 # via black
regex==2020.7.14 # via black
toml==0.10.1 # via black
typed-ast==1.4.1 # via black
typing-extensions==3.7.4.3 # via black
2 changes: 1 addition & 1 deletion tests/factories/grading_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
resource_link_id=Faker("hexify", text="^" * 32),
tool_consumer_info_product_family_code=Faker(
"random_element",
elements=["BlackBoardLearn", "moodle", "canvas", "sakai", "desire2learn",],
elements=["BlackBoardLearn", "moodle", "canvas", "sakai", "desire2learn"],
),
h_username=H_USERNAME,
h_display_name=H_DISPLAY_NAME,
Expand Down
2 changes: 1 addition & 1 deletion tests/factories/requests_.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Meta:

encoding = "utf-8"
status_code = Faker(
"random_element", elements=[200, 201, 301, 304, 401, 404, 500, 501],
"random_element", elements=[200, 201, 301, 304, 401, 404, 500, 501]
)

@post_generation
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/lms/authentication/_helpers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def test_it_returns_LTIUsers_from_authorization_headers(
assert lti_user == bearer_token_schema.lti_user.return_value

def test_it_returns_LTIUsers_from_authorization_query_string_params(
self, launch_params_auth_schema, bearer_token_schema, pyramid_request,
self, launch_params_auth_schema, bearer_token_schema, pyramid_request
):
launch_params_auth_schema.lti_user.side_effect = ValidationError(
["TEST_ERROR_MESSAGE"]
Expand All @@ -88,7 +88,7 @@ def test_it_returns_LTIUsers_from_authorization_query_string_params(
assert returned_lti_user == lti_user

def test_it_returns_LTIUsers_from_authorization_form_fields(
self, launch_params_auth_schema, bearer_token_schema, pyramid_request,
self, launch_params_auth_schema, bearer_token_schema, pyramid_request
):
launch_params_auth_schema.lti_user.side_effect = ValidationError(
["TEST_ERROR_MESSAGE"]
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/lms/authentication/_policy_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_remember_delegates_to_LTIAuthenticationPolicy(
auth_tkt_authentication_policy.remember.assert_not_called()

def test_remember_falls_back_on_AuthTktAuthenticationPolicy(
self, policy, lti_authentication_policy, auth_tkt_authentication_policy,
self, policy, lti_authentication_policy, auth_tkt_authentication_policy
):
lti_authentication_policy.authenticated_userid.return_value = None

Expand All @@ -97,7 +97,7 @@ def test_forget_delegates_to_LTIAuthenticationPolicy(
auth_tkt_authentication_policy.forget.assert_not_called()

def test_forget_falls_back_on_AuthTktAuthenticationPolicy(
self, policy, lti_authentication_policy, auth_tkt_authentication_policy,
self, policy, lti_authentication_policy, auth_tkt_authentication_policy
):
lti_authentication_policy.authenticated_userid.return_value = None

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lms/models/group_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_upsert_instructor_when_existing_matching_instructor(
self, group_info, existing_instructors
):
updated_instructor = factories.HUser(
username=group_info.instructors[1]["username"], display_name="updated",
username=group_info.instructors[1]["username"], display_name="updated"
)._asdict()

group_info.upsert_instructor(updated_instructor)
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/lms/models/lti_user_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ def test_is_learner(self, roles, is_learner):
("given" * 3, "family" * 3, "", "givengivengiven familyfamilyf…"),
],
)
def test_display_name(
given_name, family_name, full_name, expected_display_name,
):
def test_display_name(given_name, family_name, full_name, expected_display_name):
display_name_ = display_name(given_name, family_name, full_name)

assert display_name_ == expected_display_name
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/lms/resources/_js_config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_it(self, context, js_config):
}

def test_google_picker_origin_falls_back_to_lms_url_if_theres_no_custom_canvas_api_domain(
self, ai_getter, context, js_config,
self, ai_getter, context, js_config
):
context.custom_canvas_api_domain = None

Expand All @@ -55,7 +55,7 @@ def test_google_picker_origin_falls_back_to_lms_url_if_theres_no_custom_canvas_a
)

def test_it_doesnt_enable_the_canvas_file_picker_if_the_lms_isnt_Canvas(
self, context, js_config,
self, context, js_config
):
context.is_canvas = False

Expand All @@ -66,7 +66,7 @@ def test_it_doesnt_enable_the_canvas_file_picker_if_the_lms_isnt_Canvas(
self.assert_canvas_file_picker_not_enabled(js_config)

def test_it_doesnt_enable_the_canvas_file_picker_if_the_consumer_key_isnt_found_in_the_db(
self, ai_getter, js_config,
self, ai_getter, js_config
):
ai_getter.developer_key.side_effect = ConsumerKeyError()

Expand All @@ -77,7 +77,7 @@ def test_it_doesnt_enable_the_canvas_file_picker_if_the_consumer_key_isnt_found_
self.assert_canvas_file_picker_not_enabled(js_config)

def test_it_doesnt_enable_the_canvas_file_picker_if_we_dont_have_a_developer_key(
self, ai_getter, js_config,
self, ai_getter, js_config
):
ai_getter.developer_key.return_value = None

Expand All @@ -88,7 +88,7 @@ def test_it_doesnt_enable_the_canvas_file_picker_if_we_dont_have_a_developer_key
self.assert_canvas_file_picker_not_enabled(js_config)

def test_it_doesnt_enable_the_canvas_file_picker_if_theres_no_custom_canvas_course_id(
self, pyramid_request, js_config,
self, pyramid_request, js_config
):
del pyramid_request.params["custom_canvas_course_id"]

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/lms/services/canvas_api/client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_authenticated_users_sections(self, canvas_api_client, http_session):
)

def test_authenticated_users_sections_deduplicates_sections(
self, canvas_api_client, http_session,
self, canvas_api_client, http_session
):
http_session.set_response(
{"sections": [{"id": 1, "name": "name"}, {"id": 1, "name": "name"}]}
Expand Down Expand Up @@ -164,7 +164,7 @@ def test_list_files(self, canvas_api_client, http_session):
Any.request(
"GET",
url=Any.url.with_path("api/v1/courses/COURSE_ID/files").with_query(
{"content_types[]": "application/pdf", "per_page": Any.string(),}
{"content_types[]": "application/pdf", "per_page": Any.string()}
),
),
timeout=Any(),
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lms/services/course_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_it_inserts_False_if_theres_a_matching_row_in_course_groups_exported_fro
),
)
def test_any_with_setting(
self, svc, settings_set, value, expected, add_courses_with_settings,
self, svc, settings_set, value, expected, add_courses_with_settings
):
add_courses_with_settings(settings_set)
# Add a matching course with a different consumer key
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/lms/services/exceptions_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,16 @@ class TestCanvasAPIError:
[
# A 401 Unauthorized response from Canvas, because our access token was
# expired or deleted.
(401, "401 Unauthorized", CanvasAPIAccessTokenError,),
(401, "401 Unauthorized", CanvasAPIAccessTokenError),
# A 400 Bad Request response from Canvas, because we sent an invalid
# parameter or something.
(400, "400 Bad Request", CanvasAPIServerError,),
(400, "400 Bad Request", CanvasAPIServerError),
# An unexpected error response from Canvas.
(500, "500 Internal Server Error", CanvasAPIServerError,),
(500, "500 Internal Server Error", CanvasAPIServerError),
],
)
def test_it_raises_the_right_subclass_for_different_Canvas_responses(
self, status, expected_status, expected_exception_class,
self, status, expected_status, expected_exception_class
):
cause = self._requests_exception(status=status)

Expand All @@ -106,7 +106,7 @@ def test_it_raises_CanvasAccessTokenError_for_refresh_token_not_found_responses(
):
cause = self._requests_exception(
status=400,
body=json.dumps({"error_description": "refresh_token not found",}),
body=json.dumps({"error_description": "refresh_token not found"}),
)

self.assert_raises(cause, CanvasAPIAccessTokenError)
Expand Down
20 changes: 5 additions & 15 deletions tests/unit/lms/services/group_info_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ def test_it_adds_a_new_GroupInfo_if_none_exists(
self, application_instance, db_session, group_info_svc, params
):
group_info_svc.upsert(
factories.HGroup(
authority_provided_id=self.AUTHORITY, type="course_group",
),
factories.HGroup(authority_provided_id=self.AUTHORITY, type="course_group"),
consumer_key=application_instance.consumer_key,
params=params,
)
Expand All @@ -40,9 +38,7 @@ def test_it_updates_an_existing_GroupInfo_if_one_already_exists(
db_session.add(pre_existing_group)

group_info_svc.upsert(
factories.HGroup(
authority_provided_id=self.AUTHORITY, type="course_group",
),
factories.HGroup(authority_provided_id=self.AUTHORITY, type="course_group"),
consumer_key=application_instance.consumer_key,
params=dict(params, context_title="NEW_TITLE"),
)
Expand All @@ -58,9 +54,7 @@ def test_it_ignores_non_metadata_params(
self, application_instance, db_session, group_info_svc, params
):
group_info_svc.upsert(
factories.HGroup(
authority_provided_id=self.AUTHORITY, type="course_group",
),
factories.HGroup(authority_provided_id=self.AUTHORITY, type="course_group"),
consumer_key=application_instance.consumer_key,
params=dict(
params,
Expand All @@ -80,9 +74,7 @@ def test_it_records_instructors_with_group_info(
self, application_instance, db_session, group_info_svc, pyramid_request
):
group_info_svc.upsert(
factories.HGroup(
authority_provided_id=self.AUTHORITY, type="course_group",
),
factories.HGroup(authority_provided_id=self.AUTHORITY, type="course_group"),
consumer_key=application_instance.consumer_key,
params={},
)
Expand All @@ -101,9 +93,7 @@ def test_it_doesnt_record_learners_with_group_info(
self, application_instance, db_session, group_info_svc
):
group_info_svc.upsert(
factories.HGroup(
authority_provided_id=self.AUTHORITY, type="course_group",
),
factories.HGroup(authority_provided_id=self.AUTHORITY, type="course_group"),
consumer_key=application_instance.consumer_key,
params={},
)
Expand Down
4 changes: 1 addition & 3 deletions tests/unit/lms/services/h_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class TestHAPI:
# pylint: disable=protected-access

def test_bulk_action_process_commands_correctly(self, h_api, BulkAPI):
h_api.execute_bulk(
[sentinel.command_1, sentinel.command_2,]
)
h_api.execute_bulk([sentinel.command_1, sentinel.command_2])

BulkAPI.to_string.assert_called_once_with(
[
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/lms/validation/_lti_launch_params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_it_raises_if_url_not_present(self, schema):
schema.parse()

assert exc_info.value.messages == {
"form": {"url": ["Missing data for required field."],},
"form": {"url": ["Missing data for required field."]},
}

@pytest.fixture
Expand Down Expand Up @@ -213,11 +213,11 @@ def test_required_params(self, schema, pyramid_request, missing_param):
"invalid_params,expected_error_messages",
[
(
{"lti_version": "invalid version",},
{"lti_version": "invalid version"},
{"lti_version": ["Must be one of: LTI-1p0."]},
),
(
{"lti_message_type": "invalid message type",},
{"lti_message_type": "invalid message type"},
{"lti_message_type": ["Must be one of: ContentItemSelectionRequest."]},
),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_it_returns_the_lti_user_info(self, schema, display_name):
lti_user = schema.lti_user()

display_name.assert_called_once_with(
"TEST_GIVEN_NAME", "TEST_FAMILY_NAME", "TEST_FULL_NAME",
"TEST_GIVEN_NAME", "TEST_FAMILY_NAME", "TEST_FULL_NAME"
)
assert lti_user == LTIUser(
user_id="TEST_USER_ID",
Expand All @@ -26,9 +26,7 @@ def test_it_returns_the_lti_user_info(self, schema, display_name):
def test_user_info_fields_default_to_empty_strings(self, schema, display_name):
schema.lti_user()

display_name.assert_called_once_with(
"", "", "",
)
display_name.assert_called_once_with("", "", "")

def test_it_does_oauth_1_verification(self, launch_verifier, schema):
schema.lti_user()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lms/views/api/canvas/authorize_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_no_sections_scopes_if_no_courses_and_disabled(self, pyramid_request):
self.assert_file_scopes_only(authorize.authorize(pyramid_request))

def test_it_includes_the_state_in_a_query_param(
self, pyramid_request, CanvasOAuthCallbackSchema, canvas_oauth_callback_schema,
self, pyramid_request, CanvasOAuthCallbackSchema, canvas_oauth_callback_schema
):
response = authorize.authorize(pyramid_request)

Expand Down