MCPcopy
hub / github.com/pydantic/pydantic / is_valid_identifier

Function is_valid_identifier

pydantic/_internal/_utils.py:122–127  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

120
121
122def 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
130KeyType = TypeVar('KeyType')

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected