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

[pre-commit.ci] pre-commit autoupdate #167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
- .secrets.baseline
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: 'v0.5.7'
rev: 'v0.9.3'
hooks:
- id: ruff-format
- id: ruff
Expand All @@ -64,7 +64,7 @@ repos:
hooks:
- id: shellcheck
- repo: https://github.com/rhysd/actionlint
rev: v1.7.1
rev: v1.7.7
hooks:
- id: actionlint
name: actionlint
Expand Down
2 changes: 1 addition & 1 deletion src/common/mitol/common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def update(self, **kwargs):
Automatically update updated_on timestamp when .update(). This is because .update()
does not go through .save(), thus will not auto_now, because it happens on the
database level without loading objects into memory.
""" # noqa: E501, D402
""" # noqa: E501
if "updated_on" not in kwargs:
kwargs["updated_on"] = now_in_utc()
return super().update(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def handle(self, *args, **options): # noqa: ARG002
deferral_request_handler = DeferralRequestHandler()
self.stdout.write("Handling refunds and updating spreadsheet...")
results = deferral_request_handler.process_sheet(
limit_row_index=options.get("row", None)
limit_row_index=options.get("row")
)
self.stdout.write(
self.style.SUCCESS(f"Deferral sheet successfully processed.\n{results}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def handle(self, *args, **options): # noqa: ARG002
refund_request_handler = RefundRequestHandler()
self.stdout.write("Handling refunds and updating spreadsheet...")
results = refund_request_handler.process_sheet(
limit_row_index=options.get("row", None)
limit_row_index=options.get("row")
)
self.stdout.write(
self.style.SUCCESS(f"Refund sheet successfully processed.\n{results}")
Expand Down
22 changes: 11 additions & 11 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


@pytest.fixture(scope="session")
def django_db_modify_db_settings_pants_suffix() -> None: # noqa: PT004
def django_db_modify_db_settings_pants_suffix() -> None:
skip_if_no_django()

slot_id = environ.get("PANTS_EXECUTION_SLOT", None)
Expand All @@ -20,13 +20,13 @@ def django_db_modify_db_settings_pants_suffix() -> None: # noqa: PT004


@pytest.fixture(scope="session")
def django_db_modify_db_settings_parallel_suffix( # noqa: PT004
def django_db_modify_db_settings_parallel_suffix(
django_db_modify_db_settings_pants_suffix, # noqa: ARG001
) -> None:
skip_if_no_django()


@pytest.fixture()
@pytest.fixture
def learner_drf_client(learner):
"""DRF API test client that is authenticated with the user"""
# import is here to avoid trying to load django before settings are initialized
Expand All @@ -37,7 +37,7 @@ def learner_drf_client(learner):
return client


@pytest.fixture()
@pytest.fixture
def learner(db): # noqa: ARG001
"""Fixture for a default learner"""
# import is here to avoid trying to load django before settings are initialized
Expand All @@ -46,7 +46,7 @@ def learner(db): # noqa: ARG001
return UserFactory.create()


@pytest.fixture()
@pytest.fixture
def learner_and_oauth2(learner):
"""Fixture for a default learner and oauth2 records"""
# import is here to avoid trying to load django before settings are initialized
Expand All @@ -72,31 +72,31 @@ def learner_and_oauth2(learner):
)


@pytest.fixture()
@pytest.fixture
def staff_user(db): # noqa: ARG001
"""Staff user fixture"""
from mitol.common.factories import UserFactory

return UserFactory.create(is_staff=True)


@pytest.fixture()
@pytest.fixture
def user_client(learner):
"""Django test client that is authenticated with the user"""
client = Client()
client.force_login(learner)
return client


@pytest.fixture()
@pytest.fixture
def staff_client(staff_user):
"""Django test client that is authenticated with the staff user"""
client = Client()
client.force_login(staff_user)
return client


@pytest.fixture()
@pytest.fixture
def google_sheets_base_settings(settings):
"""Fixture for base google sheets settings"""
settings.MITOL_GOOGLE_SHEETS_ENROLLMENT_CHANGE_SHEET_ID = "1"
Expand All @@ -106,14 +106,14 @@ def google_sheets_base_settings(settings):
return settings


@pytest.fixture()
@pytest.fixture
def google_sheets_service_creds_settings(settings):
"""Fixture for google sheets settings configured for a service account"""
settings.MITOL_GOOGLE_SHEETS_DRIVE_SERVICE_ACCOUNT_CREDS = '{"credentials": "json"}'
return settings


@pytest.fixture()
@pytest.fixture
def google_sheets_client_creds_settings(settings):
"""Fixture gor google sheets settings configured with OAuth"""
settings.MITOL_GOOGLE_SHEETS_DRIVE_CLIENT_ID = "nhijg1i.apps.googleusercontent.com"
Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/authentication/views/test_djoser.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
EMAIL = "[email protected]"


@pytest.fixture()
@pytest.fixture
def user():
from mitol.common.factories import UserFactory

Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/common/templates/test_render_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


@pytest.fixture(autouse=True)
def dont_disable_webpack(settings): # noqa: PT004
def dont_disable_webpack(settings):
"""Re-enable webpack loader stats for these tests."""
settings.WEBPACK_DISABLE_LOADER_STATS = False

Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/common/test_envs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@


@pytest.fixture(autouse=True)
def clean_env(mocker): # noqa: PT004
def clean_env(mocker):
"""Clean the configured environment variables before a test"""
mocker.patch.dict("os.environ", FAKE_ENVIRONS, clear=True)
envs.env.reload()
Expand Down
4 changes: 2 additions & 2 deletions tests/mitol/common/utils/test_collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def __init__(self, make, model):

def test_chunks():
"""
test for chunks
Test for chunks
"""
input_list = list(range(113))
output_list = []
Expand All @@ -251,7 +251,7 @@ def test_chunks():

def test_chunks_iterable():
"""
test that chunks works on non-list iterables too
Test that chunks works on non-list iterables too
"""
count = 113
input_range = range(count)
Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/digitalcredentials/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_build_api_url_invalid(settings):
build_api_url("/path")


@pytest.mark.django_db()
@pytest.mark.django_db
def test_create_deep_link_url(settings):
"""Test create_deep_link_url()"""
settings.MITOL_DIGITAL_CREDENTIALS_AUTH_TYPE = "test_auth_type"
Expand Down
2 changes: 1 addition & 1 deletion tests/mitol/geoip/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
fake = faker.Factory.create()


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
"v4,in_block", # noqa: PT006
[
Expand Down
4 changes: 2 additions & 2 deletions tests/mitol/google_sheets/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from mitol.google_sheets.factories import GoogleApiAuthFactory


@pytest.mark.django_db()
@pytest.mark.django_db
def test_get_credentials_service_account(mocker, settings):
"""
get_credentials should construct a valid Credentials object from app settings using Service Account auth
Expand All @@ -35,7 +35,7 @@ def test_get_credentials_service_account(mocker, settings):
assert creds == patched_svc_account_creds.from_service_account_info.return_value


@pytest.mark.django_db()
@pytest.mark.django_db
def test_get_credentials_personal_auth(settings):
"""
get_credentials should construct a valid Credentials object from data and app settings using personal
Expand Down
4 changes: 2 additions & 2 deletions tests/mitol/google_sheets/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
lazy = lazy_fixture


@pytest.fixture()
@pytest.fixture
def google_api_auth(learner):
"""Fixture that creates a google auth object"""
return GoogleApiAuthFactory.create(requesting_user=learner)
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_request_auth(mocker, settings, staff_client):


@pytest.mark.parametrize("existing_auth", [lazy("google_api_auth"), None])
@pytest.mark.django_db()
@pytest.mark.django_db
def test_complete_auth(mocker, settings, learner, existing_auth): # noqa: ARG001
"""
View that handles Google auth completion should fetch a token and save/update a
Expand Down
6 changes: 3 additions & 3 deletions tests/mitol/google_sheets_deferrals/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pytest_lazy_fixtures import lf as lazy_fixture


@pytest.fixture()
@pytest.fixture
def request_csv_rows(settings):
"""Fake deferral request spreadsheet data rows (loaded from CSV)"""
fake_request_csv_filepath = os.path.join( # noqa: PTH118
Expand All @@ -25,7 +25,7 @@ def request_csv_rows(settings):
return [line.split(",") for i, line in enumerate(f.readlines()) if i > 0]


@pytest.fixture()
@pytest.fixture
def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001
"""Patched functions for pygsheets client functionality"""
Mock = mocker.Mock
Expand Down Expand Up @@ -60,7 +60,7 @@ def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001
)


@pytest.fixture()
@pytest.fixture
def google_sheets_deferral_settings(settings):
settings.MITOL_GOOGLE_SHEETS_DEFERRALS_REQUEST_WORKSHEET_ID = "1"
settings.MITOL_GOOGLE_SHEETS_DEFERRALS_PLUGINS = "app.plugins.DeferralPlugin"
Expand Down
6 changes: 3 additions & 3 deletions tests/mitol/google_sheets_refunds/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pytest_lazy_fixtures import lf as lazy_fixture


@pytest.fixture()
@pytest.fixture
def request_csv_rows(settings):
"""Fake refund request spreadsheet data rows (loaded from CSV)"""
fake_request_csv_filepath = os.path.join( # noqa: PTH118
Expand All @@ -25,7 +25,7 @@ def request_csv_rows(settings):
return [line.split(",") for i, line in enumerate(f.readlines()) if i > 0]


@pytest.fixture()
@pytest.fixture
def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001
"""Patched functions for pygsheets client functionality"""
Mock = mocker.Mock
Expand Down Expand Up @@ -60,7 +60,7 @@ def pygsheets_fixtures(mocker, db, request_csv_rows): # noqa: ARG001
)


@pytest.fixture()
@pytest.fixture
def google_sheets_refunds_settings(settings):
settings.MITOL_GOOGLE_SHEETS_REFUNDS_REQUEST_WORKSHEET_ID = "1"
settings.MITOL_GOOGLE_SHEETS_REFUNDS_PLUGINS = "app.plugins.RefundPlugin"
Expand Down
20 changes: 10 additions & 10 deletions tests/mitol/hubspot_api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@
test_object_type = "deals"


@pytest.fixture()
@pytest.fixture
def property_group():
"""Return sample group JSON"""
return {"name": "group_name", "label": "Group Label"}


@pytest.fixture()
@pytest.fixture
def content_type_obj():
"""Return a sample ContentType"""
return ContentType.objects.get_for_model(Group)


@pytest.fixture()
@pytest.fixture
def mock_hubspot_api(mocker):
"""Mock the send hubspot request method"""
return mocker.patch("mitol.hubspot_api.api.HubspotApi")


@pytest.fixture()
@pytest.fixture
def mock_search_object(mocker):
"""Return a mocked PublicObjectSearchRequest"""
return mocker.patch("mitol.hubspot_api.api.PublicObjectSearchRequest")
Expand Down Expand Up @@ -196,7 +196,7 @@ def test_delete_object_property(mock_hubspot_api, property_group):
assert result == 204 # noqa: PLR2004


@pytest.mark.django_db()
@pytest.mark.django_db
def test_get_hubspot_id():
"""Return the hubspot id if any for the specified content type and object ID"""
hubspot_obj = HubspotObjectFactory.create()
Expand All @@ -214,7 +214,7 @@ def test_format_app_id(settings, prefix):
assert api.format_app_id(object_id) == f"{prefix}-{object_id}"


@pytest.mark.django_db()
@pytest.mark.django_db
def test_upsert_object_request_new(mock_hubspot_api, content_type_obj):
"""A HubspotObject should be created after an object is synced for the first time"""
hubspot_id = "123456789"
Expand All @@ -234,7 +234,7 @@ def test_upsert_object_request_new(mock_hubspot_api, content_type_obj):
)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_upsert_object_request_exists(mock_hubspot_api):
"""upsert_object_request should try a patch hubspot API call if there's an existing Hubspot object""" # noqa: E501
hs_obj = HubspotObjectFactory.create()
Expand Down Expand Up @@ -264,7 +264,7 @@ def test_upsert_object_request_exists(mock_hubspot_api):
api.HubspotObjectType.CONTACTS.value,
],
)
@pytest.mark.django_db()
@pytest.mark.django_db
def test_upsert_object_request_missing_id( # noqa: PLR0913
mocker, mock_hubspot_api, content_type_obj, status, message, hs_type
):
Expand Down Expand Up @@ -303,7 +303,7 @@ def test_upsert_object_request_missing_id( # noqa: PLR0913
)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_upsert_object_request_other_error(mocker, mock_hubspot_api, content_type_obj):
"""If a non-dupe ApIException happens, raise it"""
object_id = 123
Expand All @@ -330,7 +330,7 @@ def test_upsert_object_request_other_error(mocker, mock_hubspot_api, content_typ


@pytest.mark.parametrize("is_primary_email", [True, False])
@pytest.mark.django_db()
@pytest.mark.django_db
def test_upsert_object_contact_dupe_email(mocker, mock_hubspot_api, is_primary_email):
"""If single hubspot contact has multiple emails matching 2+ django users, delete the other email""" # noqa: E501
dupe_hubspot_id = "123456789"
Expand Down
4 changes: 2 additions & 2 deletions tests/mitol/mail/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
User = get_user_model()


@pytest.fixture()
def email_settings(settings): # noqa: PT004
@pytest.fixture
def email_settings(settings):
"""Default settings for email tests""" # noqa: D401
settings.MITOL_MAIL_RECIPIENT_OVERRIDE = None

Expand Down
Loading
Loading