domains / / run-llama/llama_index
Semantic and consistent identifier naming
Names for variables, parameters, methods, and fields must be accurate, unambiguous, and consistent with existing conventions elsewhere in the codebase.
Names for variables, parameters, methods, and fields must be accurate, unambiguous, and consistent with existing conventions elsewhere in the codebase.
- Choose names that reflect the actual content/type, not a misleading approximation. For example, a parameter accepting a single string should be named
prompt, nottexts; a field holding arbitrary user-supplied data should becustom_fields, not the vagueextra_fields; a variable should not be namedimage_nodesif it’s untyped/Anyand doesn’t clearly hold image nodes. - Callback parameters should make their nature obvious from the name, e.g.
file_exists_callbackrather thancheck_file_exist. - Follow established prefixing conventions for async variants: use the same
a-prefix pattern consistently with sibling methods (e.g. ifaputexists, the matching getter should beaget, notget). When the base method name starts with a vowel, useasync_instead of a bareaprefix (e.g._async_ensure_initialized, not_aensure_initialized) to preserve readability. - Respect the public/private naming convention: do not export names prefixed with
_through a package’s public__init__.py; either make them public (drop the underscore) or keep them internal. - When adding new metadata keys, delimiters, or method names, check for and follow conventions already established by sibling readers/integrations/agents (e.g. reuse
page_labelinstead of introducing a redundantslide_numberkey; reusestart/stopmethod names used by other voice agent implementations rather than introducingrun). Also verify that any new delimiter or separator character cannot collide with legal characters in the data it’s splitting (e.g. avoid_as a separator for IDs that may themselves contain_). - Avoid breaking renames to existing public parameters/fields unless necessary; if a rename is required, bump the package version accordingly.