Skip to content

Modify invalid_name_checker snake case checks#1340

Open
rachelzUT wants to merge 3 commits into
pyta-uoft:masterfrom
rachelzUT:modify-invalid-name-checker
Open

Modify invalid_name_checker snake case checks#1340
rachelzUT wants to merge 3 commits into
pyta-uoft:masterfrom
rachelzUT:modify-invalid-name-checker

Conversation

@rachelzUT
Copy link
Copy Markdown
Contributor

@rachelzUT rachelzUT commented May 18, 2026

Proposed Changes

Modified the check functions in invalid_name_checker.py that use snake_case format (module, function and variable, method and attribute, and argument names), to include a suggested fix for invalid names. Added _to_snake_case helper function to parse invalid names into snake_case format and updated the tests for module, function and variable, method and attribute, and argument names to include the suggested fix.

...

Screenshots of your changes (if applicable)

Type of Change

Type Applies?
🚨 Breaking change (fix or feature that would cause existing functionality to change)
New feature (non-breaking change that adds functionality) X
🐛 Bug fix (non-breaking change that fixes an issue)
♻️ Refactoring (internal change to codebase, without changing functionality)
🚦 Test update (change that only adds or modifies tests)
📚 Documentation update (change that only updates documentation)
📦 Dependency update (change that updates a dependency)
🔧 Internal (change that only affects developers or continuous integration)

Checklist

Before opening your pull request:

  • I have performed a self-review of my changes.
    • Check that all changed files included in this pull request are intentional changes.
    • Check that all changes are relevant to the purpose of this pull request, as described above.
  • I have added tests for my changes, if applicable.
    • This is required for all bug fixes and new features.
  • I have updated the project documentation, if applicable.
    • This is required for new features.
  • I have updated the project Changelog (this is required for all changes).
  • If this is my first contribution, I have added myself to the list of contributors.

After opening your pull request:

  • I have verified that the CI tests have passed.
  • I have reviewed the test coverage changes reported by Coveralls.
  • I have requested a review from a project maintainer.

Questions and Comments

@coveralls
Copy link
Copy Markdown
Collaborator

Coverage Report for CI Build 26054787114

Coverage increased (+0.01%) to 90.553%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: 6 of 6 lines across 1 file are fully covered (100%).
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 3885
Covered Lines: 3518
Line Coverage: 90.55%
Coverage Strength: 17.57 hits per line

💛 - Coveralls

@rachelzUT rachelzUT requested a review from david-yz-liu May 18, 2026 19:23

def _to_snake_case(name: str) -> str:
"""Converts a name to snake_case format."""
return re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name).lower()
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.

In the _is_in_snake_case method, the regex also requires that the name begin with a letter (a-z). However, the current suggested approach will not correctly return a word that is in snake case.

In general I think it's hard to generate a good suggestion if the variable doesn't start with a letter already.

So I recommend (1) modifying the return type to str | None, returning None when no valid suggestion can be generated, and (2) modifying the check functions below to only display the suggested fix if one is returned.

f'Module name "{name}" should be in snake_case format. Modules should be all-lowercase '
f"names, with each name separated by underscores."
f"names, with each name separated by underscores. "
f'Suggested fix: "{suggested_name}".'
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.

In general, if there is a suggestion then I'd like it to appear in the second sentence, e.g. f'Module name "{name}" should be in snake_case format. Suggested fix: ...'

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.

3 participants