Skip to content

Housekeeping: Various linter fixes#3449

Open
max-moser wants to merge 4 commits into
inveniosoftware:masterfrom
max-moser:mm/housekeeping
Open

Housekeeping: Various linter fixes#3449
max-moser wants to merge 4 commits into
inveniosoftware:masterfrom
max-moser:mm/housekeeping

Conversation

@max-moser
Copy link
Copy Markdown
Contributor

Fix some complaints made by ruff

* the __all__ variable should be a list of strings, but previously it
  was a simple string
Comment thread tests/ui/test_sitemaps.py Outdated
community_input["slug"] = "my-test-community-2"
community_input["access"]["visibility"] = "restricted"
c2 = create_community(data=community_input)
_c2 = create_community(data=community_input)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: why not remove the assignment entirely?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because that left a "hole" in the naming (c1, c3) that i think would likely create more confusion than the rename
i also toyed with the thought of removing c2 and renaming c3 to c2, but that didn't feel great either

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now i am confused, i thought all of them are not used? so c1, c2, c3 are useless variables?

Copy link
Copy Markdown
Contributor Author

@max-moser max-moser May 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, it seems like i mixed up the cX variables here with the other named & unused variables below (rX, draft_only, record_with_draft, ...): it's actually the removal of r2 that would cause the "hole" between r1 and r3

looking at it again, we can remove all the cX variables as they're not used; i just took the same approach for all the variables.
for the others, the names do seem to convey some sort of semantics, so i'd keep them.

Comment thread invenio_app_rdm/redirector/resource.py Outdated
if callable(target):
target_output = redirect_url()
if type(target_output) == tuple:
if isinstance(target_output, tuple):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although correct, there is a little nuance with this change: isinstance is aware of inheritance, type() == is not.
I don't expect this to cause any issues here, I'm probably just pointing it out because it has caused "unexpected behaviours" for me in the past 😅

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point!
i've replaced the check now with type(...) is tuple, which also made the linter happy and preserves the semantics better 😄

@egabancho egabancho self-requested a review May 13, 2026 07:25
max-moser added 2 commits May 13, 2026 10:32
* as suggested by the linter `ruff`
* move imports to the top of the file
* remove unused imports
* rename unused variables
* the removed function definition was shadowed by another one with the
  same name right below it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants