Skip to content

Commit

Permalink
chore(dev-deps): update ruff from 0.4 to 0.6 (#102)
Browse files Browse the repository at this point in the history
* chore: update ruff

* chore: ruff findings
  • Loading branch information
GabDug authored Sep 27, 2024
1 parent d2c2e26 commit 2e1811d
Show file tree
Hide file tree
Showing 27 changed files with 139 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
- id: fix-byte-order-marker
# Versions must be kept in sync with lockfile
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.4.10'
rev: 'v0.6.8'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
37 changes: 19 additions & 18 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ select = ["ALL"]

ignore = [
"A003", # Class attribute is shadowing a python builtin - Too many false positive and no way to exclude (yet?)
"A005", # Module `*` is shadowing a Python builtin module
"ARG001", # XXX Enable later - No way to specify which args to ignore
"ANN", # XXX Enable later - More than 400 annotations errors
"ANN101", # Missing type annotation for `self` in method
Expand All @@ -509,6 +510,10 @@ ignore = [
"D107",
"D401", # First line of docstring should be in imperative mood
"D205", # 1 blank line required between summary line and description
"DOC201", # `return` is not documented in docstring
"DOC402", # `yield` is not documented in docstring
"DOC501", # Raised exception `*` missing from docstring
"DOC502", # Raised exception is not explicitly raised: `*`
"E501", # Line too long
"EM101", # Exceptions should not use a string literal but a variable
"PLR2004", # Too aggressive, but some good points
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/incidents/models/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ def update_roles(

return incident_update

def create_incident_update( # noqa: PLR0913
def create_incident_update(
self: Incident,
message: str | None = None,
status: int | None = None,
Expand Down
3 changes: 1 addition & 2 deletions src/firefighter/slack/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ def save_model(
group_slack_id=obj.usergroup_id
)
elif obj.handle:
if obj.handle.startswith("@"):
obj.handle = obj.handle[1:]
obj.handle = obj.handle.removeprefix("@")
obj.handle.strip()
fetch_obj = UserGroup.objects.fetch_usergroup(group_handle=obj.handle)
if fetch_obj:
Expand Down
2 changes: 1 addition & 1 deletion src/firefighter/slack/signals/incident_updated.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def incident_updated_update_status_handler(
incident=incident,
incident_update=incident_update,
status_changed=bool("_status" in updated_fields),
old_priority=kwargs.get("old_priority", None),
old_priority=kwargs.get("old_priority"),
)


Expand Down
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def _debug(settings: SettingsWrapper) -> None:
template["OPTIONS"]["debug"] = True


@pytest.fixture()
@pytest.fixture
def main_heading() -> str:
"""An example fixture containing some html fragment."""
return '<p class="mt-2 text-sm text-base-content text-opacity-80">Report, manage, escalate!</p>'


@pytest.fixture(scope="session")
def django_db_setup( # noqa: PT004
def django_db_setup(
django_db_setup: Any, django_db_blocker: DjangoDbBlocker
) -> None:
# XXX Allow override of fixtures path
Expand Down Expand Up @@ -76,13 +76,13 @@ def django_db_setup( # noqa: PT004
django_db_blocker.restore()


@pytest.fixture()
@pytest.fixture
def incident() -> Incident:
return IncidentFactory.build()


@pytest.fixture()
@pytest.mark.django_db()
@pytest.fixture
@pytest.mark.django_db
def incident_saved() -> Incident:
incident: Incident = IncidentFactory.build()
incident.component.group.save()
Expand Down
8 changes: 4 additions & 4 deletions tests/test_api/test_api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_api_schema(client: Client) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incidents_cost_api(admin_client: Client, admin_user: User) -> None:
"""This test ensures that the incidents costs API endpoint is accessible for an admin"""
admin_client.force_login(admin_user)
Expand All @@ -31,7 +31,7 @@ def test_incidents_cost_api(admin_client: Client, admin_user: User) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incidents_cost_api_unauthorized(client: Client) -> None:
"""This test ensures that the incidents costs API endpoint is not accessible for a guest user"""
user = UserFactory.create()
Expand All @@ -41,7 +41,7 @@ def test_incidents_cost_api_unauthorized(client: Client) -> None:
assert response.status_code == 403


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incidents_cost_type_api(admin_client: Client, admin_user: User) -> None:
"""This test ensures that the incidents cost types API endpoint is accessible for an admin"""
admin_client.force_login(admin_user)
Expand All @@ -50,7 +50,7 @@ def test_incidents_cost_type_api(admin_client: Client, admin_user: User) -> None
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incidents_cost_api_type_unauthorized(client: Client) -> None:
"""This test ensures that the incidents costs API endpoint is not accessible for a guest user"""
user = UserFactory.create()
Expand Down
24 changes: 12 additions & 12 deletions tests/test_firefighter/test_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,23 @@
logger = logging.getLogger(__name__)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_health_check(client: Client) -> None:
"""This test ensures that health check is accessible."""
response = client.get("/api/v2/firefighter/monitoring/healthcheck")

assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
def test_admin_unauthorized(client: Client) -> None:
"""This test ensures that admin panel requires auth."""
response = client.get("/admin/")

assert response.status_code == 302


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.usefixtures("_debug")
def test_admin_authorized(admin_client: Client, admin_user: User) -> None:
"""This test ensures that admin panel is accessible."""
Expand All @@ -44,7 +44,7 @@ def test_admin_authorized(admin_client: Client, admin_user: User) -> None:
assert response.status_code == 200


@pytest.mark.django_db()
@pytest.mark.django_db
def test_admin_docs_unauthorized(client: Client) -> None:
"""This test ensures that admin panel docs requires auth."""
response = client.get("/admin/doc/")
Expand All @@ -54,7 +54,7 @@ def test_admin_docs_unauthorized(client: Client) -> None:
assert response.url == "/admin/login/?next=/admin/doc/"


@pytest.mark.django_db()
@pytest.mark.django_db
def test_admin_docs_authorized(admin_client: Client) -> None:
"""This test ensures that admin panel docs are accessible."""
response = admin_client.get("/admin/doc/")
Expand All @@ -63,7 +63,7 @@ def test_admin_docs_authorized(admin_client: Client) -> None:
assert b"docutils" not in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_robotstxt_present(client: Client) -> None:
"""This test ensures that robots.txt is present."""
response = client.get("/robots.txt")
Expand All @@ -72,7 +72,7 @@ def test_robotstxt_present(client: Client) -> None:
assert b"Disallow: /" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_login_sso_button_admin_login(client: Client) -> None:
"""This test ensures that login page contains the SSO button."""
response = client.get("/admin/login/")
Expand All @@ -81,7 +81,7 @@ def test_login_sso_button_admin_login(client: Client) -> None:
assert b"Log in with SSO" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_500_pretty(client: Client) -> None:
"""This test ensures that 500 error page is pretty."""
with pytest.raises(Exception, match="Test exception for 500"): # noqa: PT012
Expand All @@ -91,7 +91,7 @@ def test_error_500_pretty(client: Client) -> None:
assert b"Please try again later, and report it" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_404_pretty(client: Client) -> None:
"""This test ensures that 404 error page is pretty."""
response = client.get("/err/404/")
Expand All @@ -100,7 +100,7 @@ def test_error_404_pretty(client: Client) -> None:
assert b"Please check the URL in the address bar and try again" in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_403_pretty(client: Client) -> None:
"""This test ensures that 403 error page is pretty."""
response = client.get("/err/403/")
Expand All @@ -109,7 +109,7 @@ def test_error_403_pretty(client: Client) -> None:
assert b"You do not have permission to access this page." in response.content


@pytest.mark.django_db()
@pytest.mark.django_db
def test_error_400_pretty(client: Client) -> None:
"""This test ensures that 400 error page is pretty."""
response = client.get("/err/400/")
Expand All @@ -129,7 +129,7 @@ def test_errors_json(client: Client) -> None:
assert json.loads(response.content).get("error") is not None


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.timeout(30)
@pytest.mark.usefixtures("_debug")
def test_all_admin_list_no_error(admin_client: Client, admin_user: User) -> None:
Expand Down
6 changes: 3 additions & 3 deletions tests/test_incidents/test_forms/test_form_select_impact.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from firefighter.incidents.forms.select_impact import SelectImpactForm


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("form_data", "expected_priority"),
[
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_suggest_priority_from_impact(form_data, expected_priority):
assert priority == expected_priority


@pytest.mark.django_db()
@pytest.mark.django_db
@pytest.mark.parametrize(
("form_data", "expected_priority"),
[
Expand Down Expand Up @@ -96,7 +96,7 @@ def test_suggest_priority_from_impact(form_data, expected_priority):
),
],
)
@pytest.mark.django_db()
@pytest.mark.django_db
def test_suggest_priority_from_impact_with_invalid_form(form_data, expected_priority):
form = SelectImpactForm(data=form_data)
assert not form.is_valid()
Expand Down
8 changes: 4 additions & 4 deletions tests/test_incidents/test_forms/test_form_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class GroupedModelChoiceFieldForm(Form):
)


@pytest.fixture()
@pytest.fixture
def group() -> Group:
return Group.objects.create(name="Group 1")


@pytest.fixture()
@pytest.fixture
def components(group: Group):
return [
Component.objects.create(name="Component 1", group=group, order=1),
Expand All @@ -46,7 +46,7 @@ def test_enum_choice_field_invalid() -> None:
assert "status" in form.errors


@pytest.mark.django_db()
@pytest.mark.django_db
def test_grouped_model_choice_field_valid(components: list[Component]):
form = GroupedModelChoiceFieldForm({"component": components[0].id})
assert form.is_valid()
Expand All @@ -60,7 +60,7 @@ def test_grouped_model_choice_field_invalid() -> None:


@pytest.fixture(scope="module")
def test_grouped_model_choice_field_grouping( # noqa: PT004
def test_grouped_model_choice_field_grouping(
components: list[Component],
):
form = GroupedModelChoiceFieldForm()
Expand Down
6 changes: 3 additions & 3 deletions tests/test_incidents/test_forms/test_update_key_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from firefighter.incidents.models.milestone_type import MilestoneType


@pytest.fixture()
@pytest.fixture
def user() -> User:
return User.objects.create_user(username="testuser")


@pytest.fixture()
@pytest.fixture
def milestone_type() -> MilestoneType:
return MilestoneType(
event_type="detected",
Expand All @@ -26,7 +26,7 @@ def milestone_type() -> MilestoneType:
)


@pytest.mark.django_db()
@pytest.mark.django_db
def test_incident_update_key_events_form(
user: User, incident_saved: Incident, milestone_type: MilestoneType
):
Expand Down
Loading

0 comments on commit 2e1811d

Please sign in to comment.