Skip to content

Add Python identifier sanitization helpers#81

Open
ncoop57 wants to merge 2 commits intomainfrom
sanitize-py
Open

Add Python identifier sanitization helpers#81
ncoop57 wants to merge 2 commits intomainfrom
sanitize-py

Conversation

@ncoop57
Copy link
Contributor

@ncoop57 ncoop57 commented Mar 25, 2026

Adds utility functions for sanitizing arbitrary strings into valid Python identifiers:

  • _norm_nm: Normalizes names by replacing non-word characters
  • _py_nm: Converts strings to valid Python identifiers (handles leading digits, keywords)
  • _nm_map: Builds a mapping from sanitized names back to originals with collision detection

Also includes minor cleanup: removed unused imports, modernized type hints (str | None style), and collapsed some single-statement conditionals.

@ncoop57 ncoop57 added the enhancement New feature or request label Mar 25, 2026
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant