Checks that a string is a valid identifier and not a Python keyword. :param identifier: The identifier to test. :return: True if the identifier is valid.
(identifier: str)
| 120 | |
| 121 | |
| 122 | def is_valid_identifier(identifier: str) -> bool: |
| 123 | """Checks that a string is a valid identifier and not a Python keyword. |
| 124 | :param identifier: The identifier to test. |
| 125 | :return: True if the identifier is valid. |
| 126 | """ |
| 127 | return identifier.isidentifier() and not keyword.iskeyword(identifier) |
| 128 | |
| 129 | |
| 130 | KeyType = TypeVar('KeyType') |
no outgoing calls
no test coverage detected