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

Ruff upgrade #1262

Merged
merged 7 commits into from
Jul 9, 2024
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
5 changes: 1 addition & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@
## 🎫 Tickets
[//]: # "This pull request resolves all or part of the following ticket(s)."

- [TILA-][TILA]


[TILA]: https://helsinkisolutionoffice.atlassian.net/browse/TILA-
- [TILA-](https://helsinkisolutionoffice.atlassian.net/browse/TILA-)
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
args: ["--markdown-linebreak-ext=md"]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.4.10
rev: v0.5.1
hooks:
- id: ruff
- id: ruff-format
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,7 @@ def _prefill_reservation_from_profile(self, data: dict[str, Any]) -> None:
return

if prefill_info is not None:
for key, value in prefill_info.items():
if value is not None:
data[key] = value
data.update({key: value for key, value in prefill_info.items() if value is not None})

def check_sku(self, current_sku, new_sku) -> None:
if current_sku is not None and current_sku != new_sku:
Expand Down
411 changes: 206 additions & 205 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ lint.select = [
"FA", # flake8-future-annotations
#"FBT", # flake8-boolean-trap # TODO: Enable this and fix (95) issues
"FLY", # flynt
"FURB", # refurb
#"G", # flake8-logging-format # TODO: Enable this and fix (20) issues
"I", # isort
"ICN", # flake8-import-conventions
Expand Down Expand Up @@ -154,12 +155,10 @@ lint.extend-select = [
"FURB142", # for-loop-set-mutations
"FURB145", # slice-copy
"FURB171", # single-item-membership-test
"FURB187", # list-reverse-copy
"PLE0307", # invalid-str-return-type
"PLR0916", # too-many-boolean-expressions
"PLR1730", # if-stmt-min-max
"PLR1733", # unnecessary-dict-index-lookup
"PLR1736", # unnecessary-list-index-lookup
"PLR6104", # non-augmented-assignment
"PLW0211", # bad-staticmethod-argument
"PLW0642", # self-or-cls-assignment
Expand Down Expand Up @@ -190,6 +189,9 @@ lint.ignore = [
# Any-typing allowed
"ANN401", # any-type

# Allow empty comments. We use emtpy comments for forcing better code formatting.
"PLR2044", # empty-comment

# To be enabled in the future
"DJ001", # Allow `null=True` in text-based fields TODO: Remove this ignore once the issues are fixed.
"PLR2004", # magic-value-comparison
Expand Down
6 changes: 3 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
from django.core.mail import EmailMessage


@pytest.fixture()
@pytest.fixture
def graphql() -> GraphQLClient:
return GraphQLClient()


@pytest.fixture()
@pytest.fixture
def api_client() -> APIClient:
return APIClient()

Expand All @@ -29,7 +29,7 @@ def _enable_elasticsearch(request, settings):
settings.SEARCH_SETTINGS["settings"]["auto_sync"] = use_elasticsearch


@pytest.fixture()
@pytest.fixture
def outbox() -> list[EmailMessage]:
from django.core import mail

Expand Down
7 changes: 0 additions & 7 deletions tests/factories/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,6 @@ class Meta:
id = factory.LazyFunction(uuid.uuid4)
merchant = factory.SubFactory("tests.factories.PaymentMerchantFactory")

@factory.post_generation
def merchant(self, create, merchant, **kwargs):
if not create or not merchant:
return

self.merchant = merchant


class PaymentOrderFactory(GenericDjangoModelFactory[PaymentOrder]):
class Meta:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
]


@pytest.fixture()
@pytest.fixture
def services():
return ServiceFactory.create_batch(3)


@pytest.fixture()
@pytest.fixture
def res_unit_parent(services):
space_parent = SpaceFactory.create()
return ReservationUnitFactory.create(services=services, spaces=[space_parent])


@pytest.fixture()
@pytest.fixture
def res_unit_child_1(services, res_unit_parent):
space_child_1 = SpaceFactory.create(parent=res_unit_parent.spaces.first())
return ReservationUnitFactory.create(services=services, spaces=[space_child_1])


@pytest.fixture()
@pytest.fixture
def res_unit_child_2(services, res_unit_parent):
space_child_2 = SpaceFactory.create(parent=res_unit_parent.spaces.first())
return ReservationUnitFactory.create(services=services, spaces=[space_child_2])


@pytest.fixture()
@pytest.fixture
def res_unit_child_2_child(services, res_unit_child_2):
space_child_2_child = SpaceFactory.create(parent=res_unit_child_2.spaces.first())
return ReservationUnitFactory.create(services=services, spaces=[space_child_2_child])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


# TODO: Remove the need to have this fixture in this file
@pytest.fixture()
@pytest.fixture
def reservation_unit() -> ReservationUnit:
return ReservationUnitFactory(
origin_hauki_resource=OriginHaukiResourceFactory(id=999, opening_hours_hash="abc123"),
Expand Down
4 changes: 2 additions & 2 deletions tests/test_email/test_email_builder_render_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
]


@pytest.fixture()
@pytest.fixture
def email_template() -> EmailTemplate:
html_file_fi = SimpleUploadedFile(name="mock_file_fi.html", content=b"HTML content FI")
html_file_en = SimpleUploadedFile(name="mock_file_en.html", content=b"HTML content EN")
Expand All @@ -32,7 +32,7 @@ def email_template() -> EmailTemplate:
)


@pytest.fixture()
@pytest.fixture
def application() -> Application:
return ApplicationFactory.create(user__preferred_language="fi")

Expand Down
4 changes: 2 additions & 2 deletions tests/test_email/test_email_builder_render_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
]


@pytest.fixture()
@pytest.fixture
def email_template() -> EmailTemplate:
html_file_fi = SimpleUploadedFile(name="mock_file_fi.html", content=b"HTML content FI")
html_file_en = SimpleUploadedFile(name="mock_file_en.html", content=b"HTML content EN")
Expand All @@ -36,7 +36,7 @@ def email_template() -> EmailTemplate:
)


@pytest.fixture()
@pytest.fixture
def reservation() -> Reservation:
return ReservationFactory.create(name="Test reservation")

Expand Down
2 changes: 1 addition & 1 deletion tests/test_email/test_email_context_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
]


@pytest.fixture()
@pytest.fixture
def reservation() -> Reservation:
reservation_unit = ReservationUnitFactory.create(
name_fi="ReservationUnit Name FI",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_email/test_email_sender_reservation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
]


@pytest.fixture()
@pytest.fixture
def email_template() -> EmailTemplate:
return EmailTemplateFactory.create(
type=EmailType.RESERVATION_CONFIRMED,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_external_services/test_hauki/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _force_HaukiAPIClient_to_be_mocked():
yield


@pytest.fixture()
@pytest.fixture
def reservation_unit() -> ReservationUnit:
return ReservationUnitFactory(
origin_hauki_resource=OriginHaukiResourceFactory(id=999, opening_hours_hash="abc123"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]


@pytest.fixture()
@pytest.fixture
def order():
reservation = ReservationFactory.create(state=ReservationStateChoice.WAITING_FOR_PAYMENT)
return PaymentOrderFactory.create(created_at=local_datetime(), reservation=reservation, status=OrderStatus.DRAFT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def dt(*, year: int = 2024, month: int = 1, day: int = 1, hour: int = 0, minute:
YESTERDAY = _datetime(year=2023, month=12, day=31)


@pytest.fixture()
@pytest.fixture
def reservation_unit() -> ReservationUnit:
origin_hauki_resource = OriginHaukiResourceFactory(
id="999",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
UTCOFFSET = f"0{int(datetime.datetime(2021, 5, 1, tzinfo=DEFAULT_TIMEZONE).utcoffset().total_seconds()/3600)}:00"


@pytest.fixture()
@pytest.fixture
def reservation_unit() -> ReservationUnit:
origin_hauki_resource = OriginHaukiResourceFactory(
id="999",
Expand Down
Loading