Back to all reviewers

Follow Python naming conventions

open-telemetry/opentelemetry-python
Based on 5 comments
Python

Use consistent Python naming conventions to improve code readability and maintainability: 1. Use snake_case for functions and variables: ```python # Bad

Naming Conventions Python

Reviewer Prompt

Use consistent Python naming conventions to improve code readability and maintainability:

  1. Use snake_case for functions and variables: ```python

    Bad

    def setifnotnone(dic, key, value):

Good

def set_if_not_none(dic, key, value):


2. Choose descriptive, semantic names that reflect purpose:
```python
# Bad
lst = []  # unclear what this list tracks

# Good
calls = []  # clearly indicates list tracks function calls
  1. Maintain consistent naming with established patterns:
    • Use standard type names (e.g., ‘Attributes’ instead of ‘dict’ for typed parameters)
    • Follow existing naming patterns in the codebase (e.g., ‘trace_exporter’ vs ‘span_exporter’)
    • Use semantic names that align with specifications and documentation
  2. For internal/private variables, use single leading underscore and consistent suffixes: ```python

    Bad

    self.currentValue = None self.previous_cumulative_value = None

Good

self._value = None self._previous_value = None ```

5
Comments Analyzed
Python
Primary Language
Naming Conventions
Category

Source Discussions