Dark magics about variable names in python
Overall
score
90%
{
"context": "This criteria evaluates how well the engineer uses the varname package's nameof function to retrieve variable names and build configuration dictionaries. The focus is on correct usage of nameof with single/multiple arguments, understanding vars_only parameter, and proper handling of attribute chains.",
"type": "weighted_checklist",
"checklist": [
{
"name": "Import nameof",
"description": "Imports the nameof function from the varname package",
"max_score": 10
},
{
"name": "Basic nameof usage",
"description": "Uses nameof() correctly in build_config to retrieve variable names for multiple arguments, returning a tuple when multiple arguments are passed",
"max_score": 25
},
{
"name": "Single argument handling",
"description": "Correctly handles the case where nameof returns a string (not tuple) when called with a single argument",
"max_score": 15
},
{
"name": "Dictionary construction",
"description": "Properly constructs dictionary by pairing returned names from nameof with the actual argument values",
"max_score": 15
},
{
"name": "Prefix implementation",
"description": "Implements build_config_with_prefix using nameof and correctly prepends the prefix to each variable name",
"max_score": 15
},
{
"name": "Full path extraction",
"description": "Uses nameof with vars_only=False parameter in get_full_path to retrieve the complete attribute chain (e.g., 'obj.attr.subattr')",
"max_score": 20
}
]
}Install with Tessl CLI
npx tessl i tessl/pypi-varnameevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10