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

add pre-commit with ruff and typos, run --all-files #13

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dyollb
Copy link
Contributor

@dyollb dyollb commented Sep 14, 2024

add pre-commit

  • standard hooks(new lines, shebangs)
  • ruff (without ruff-format, i.e. no automatic formatting as requested by owner)
  • typos

run pre-commit

  • pre-commit run --all-files

identified possible bug(s):

for segment in segments:
    if segment_name == segments["name"]: # probably should be segment["name"]
        ...    

@@ -689,7 +745,7 @@ def terminology_entry_matches(terminology1, terminology2):
def segment_id_from_name(segmentation, segment_name):
segments = segmentation["segments"]
for segment in segments:
if segment_name == segments["name"]:
if segment_name == segment["name"]:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was probably wrong...?

Copy link
Owner

Choose a reason for hiding this comment

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

Yes, good catch

Copy link
Owner

Choose a reason for hiding this comment

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

Could you please also change segments["id"] below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Owner

@lassoan lassoan left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your efforts. It all looks good except a few small things that I commented on.

multiple_layers = True
elif header_key == "kinds":
if header[header_key] == ["domain", "domain", "domain"]:
multiple_layers = False # noqa: F841
Copy link
Owner

Choose a reason for hiding this comment

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

If we don't use multiple_layers then it is probably better to convert this to a comment than adding noqa

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -689,7 +745,7 @@ def terminology_entry_matches(terminology1, terminology2):
def segment_id_from_name(segmentation, segment_name):
segments = segmentation["segments"]
for segment in segments:
if segment_name == segments["name"]:
if segment_name == segment["name"]:
Copy link
Owner

Choose a reason for hiding this comment

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

Yes, good catch

@@ -689,7 +745,7 @@ def terminology_entry_matches(terminology1, terminology2):
def segment_id_from_name(segmentation, segment_name):
segments = segmentation["segments"]
for segment in segments:
if segment_name == segments["name"]:
if segment_name == segment["name"]:
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please also change segments["id"] below?

slicerio/server.py Outdated Show resolved Hide resolved
if not auto_start:
raise

if retry_after_starting_server:
# Try again, with starting a server first
server_process = start_server(slicer_executable)
server_process = start_server(slicer_executable) # noqa: F841
Copy link
Owner

Choose a reason for hiding this comment

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

Why the noqa?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

server_process is not used

Copy link
Contributor Author

@dyollb dyollb Sep 14, 2024

Choose a reason for hiding this comment

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

I removed server_process

Copy link
Owner

Choose a reason for hiding this comment

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

Ok, you can then it is better to delete server_process =

},
]
],
Copy link
Owner

Choose a reason for hiding this comment

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

Many of these extra commas are actually misleading. The commas should be removed from all places where no additional list items are allowed. Extra line breaks make the code harder to read. It would be better to let the programmer decide where to break lines, as it is a result of conscious decisions not some simplistic rules about limiting line length. Same for indentation.

I don't want to ask you to undo all line break and indentation changes, as it could be a lot of work. But let's just undo those changes in this file and make sure the formatter does not try to change this anywhere (so I can later revert annoying changes).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can just undo the changes and disable the ruff-format hook, since you obviously don't like the black-style formatting.

@dyollb
Copy link
Contributor Author

dyollb commented Oct 7, 2024

@lassoan i think all comments are addressed. Do you want to have a look? Thanks

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.

2 participants