Skip to content

Mirror of 390#7

Open
Droid-An wants to merge 5 commits intoCodeYourFuture:mainfrom
Droid-An:mirror-of-390
Open

Mirror of 390#7
Droid-An wants to merge 5 commits intoCodeYourFuture:mainfrom
Droid-An:mirror-of-390

Conversation

@Droid-An
Copy link
Copy Markdown
Collaborator

No description provided.

@Droid-An Droid-An added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 29, 2026
@cyf-ai-code-reviewer
Copy link
Copy Markdown

Thanks for opening a new PR! AI started to review it

@github-actions

This comment has been minimized.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 29, 2026
Comment on lines +31 to +42
def filter_hidden(files: list[str]) -> list[str]:
return [name for name in files if not name.startswith(".")]


def get_visible_entries(files: list[str], include_hidden: bool):
return files if include_hidden else filter_hidden(files)


def format_entries(files: list[str], one_per_line: bool):
if len(files) == 0:
return
print(("\n" if one_per_line else "\t").join(files))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The parameter 'files' in 'format_entries', 'filter_hidden', and 'get_visible_entries' is used for both files and directory entries, which could be files or directories. Do you think a more general name like 'entries' would make it clearer that these lists can contain both files and directories?

Comment on lines +76 to +79
for directory, contents in result_dirs.items():
print("\n" + directory + ":")
filtered = get_visible_entries(contents, include_hidden)
format_entries(filtered, one_per_line)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In the section where you print directory contents for multiple directories, the logic for filtering and formatting entries is repeated. If you needed to change how entries are displayed, you'd have to update it in more than one place. How could you refactor this to avoid repeating yourself?

@github-actions

This comment has been minimized.

@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. NotCoursework labels Mar 29, 2026
@cyf-ai-code-reviewer
Copy link
Copy Markdown

Thanks for opening a new PR! AI started to review it

Comment on lines +35 to +36
def get_visible_entries(files: list[str], include_hidden: bool):
return files if include_hidden else filter_hidden(files)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The function 'get_visible_entries' returns either all files or only non-hidden files, depending on the 'include_hidden' flag. The name 'get_visible_entries' might suggest it always returns only visible (non-hidden) entries, but it can also return hidden ones. Could you think of a name that more clearly describes what this function does based on its parameters?

@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 29, 2026
@cyf-ai-code-reviewer
Copy link
Copy Markdown

Thanks for opening a new PR! AI started to review it

Comment on lines +58 to +62
# Is a file?
if stat.S_ISREG(st.st_mode):
result_files.append(file_path)
# Is a directory?
if stat.S_ISDIR(st.st_mode):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've noticed that you have comments like '# Is a file?' and '# Is a directory?' right above the code that checks if a path is a file or directory. Since the code itself (using stat.S_ISREG and stat.S_ISDIR) is already quite clear about what it's doing, these comments don't add much value. When code is self-explanatory, extra comments can sometimes make the code harder to read by adding clutter. How might you decide when a comment is truly helpful versus when the code speaks for itself?

@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 8, 2026
@cyf-ai-code-reviewer
Copy link
Copy Markdown

Thanks for opening a new PR! AI started to review it

Comment on lines +39 to +43
def format_entries(files: list[str], one_per_line: bool):
if len(files) == 0:
return
print(("\n" if one_per_line else "\t").join(files))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The logic for formatting and printing entries is used in multiple places (for files and for directories). If you find yourself repeating similar code, how might you extract it into a function to avoid duplication and make future changes easier?

Comment on lines +58 to +59
# Is a file?
if stat.S_ISREG(st.st_mode):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've noticed you added comments like '# Is a file?' and '# Is a directory?' right above the code that checks if a path is a file or directory. Since the code itself (using stat.S_ISREG and stat.S_ISDIR) is already quite clear about what it's doing, these comments don't add much extra information. When code is self-explanatory, it's often better to avoid comments like these, as they can clutter the code and make it harder to spot comments that actually explain something non-obvious. What do you think about relying on clear variable names and code structure to make your intent clear, and saving comments for places where the code might not be so obvious?

Comment on lines +61 to +62
# Is a directory?
if stat.S_ISDIR(st.st_mode):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here, you have a comment '# Is a directory?' right before checking if a path is a directory. Since the function name and the code itself make it clear what's happening, this comment doesn't really add new information. Do you think the code would be just as understandable without this comment? Sometimes, removing obvious comments can make your code cleaner and easier to maintain.

@Droid-An Droid-An added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 8, 2026
@cyf-ai-code-reviewer
Copy link
Copy Markdown

Thanks for opening a new PR! AI started to review it

Comment on lines +35 to +36
def get_visible_entries(files: list[str], include_hidden: bool):
return files if include_hidden else filter_hidden(files)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The function 'get_visible_entries' returns either all files or only non-hidden files, depending on the 'include_hidden' flag. The name 'get_visible_entries' might suggest it always returns only visible (non-hidden) files, but in fact, it sometimes returns all files including hidden ones. Could you think of a name that more clearly describes what this function does in both cases?

Comment on lines +81 to +85
print(tabulate(rows, headers=[
"index"] + output_columns))
else:
print(tabulate(rows, headers=[
"index"] + output_columns))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In your code, you have two branches (with and without options) that both print the table using 'tabulate', but the code is almost identical. If you ever wanted to change how you print the table, you'd have to remember to change it in both places. How could you avoid this duplication?

Comment on lines +58 to +62
# Is a file?
if stat.S_ISREG(st.st_mode):
result_files.append(file_path)
# Is a directory?
if stat.S_ISDIR(st.st_mode):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've noticed you added comments like '# Is a file?' and '# Is a directory?' right above the code that checks if a path is a file or directory. Since the code itself (using stat.S_ISREG and stat.S_ISDIR) is already quite clear about what it's doing, these comments don't add much extra information. When code is self-explanatory, do you think it's helpful to add comments like these, or could it make the code harder to read by adding clutter? How might you decide when a comment is truly needed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. NotCoursework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants