What's the problem this feature will solve?
Avoid writing extra code to convert data type from string to a numeric type (integer, float, etc)
Describe the solution you'd like
Parser.addini method receives a parameter called type that can be any of these string literals:
type: Optional[
"Literal['string', 'paths', 'pathlist', 'args', 'linelist', 'bool']"
] = None,
Add the literals (int, float) and have pytest to do the type check and conversion behind the scene.
Alternative Solutions
parser.addini(
"my_param",
type="string",
default="1.0",
help="My float param."
)
def my_param(request):
try:
return float(request.config.getini("my_param"))
except:
return 1.0 #The default value set with default="1.0",
With the implementation of this feature, this can be reduced to this;
parser.addini(
"my_param",
type="float",
default="1.0",
help="My float param."
)
def my_param(request):
return request.config.getini("my_param")
Additional context
What's the problem this feature will solve?
Avoid writing extra code to convert data type from string to a numeric type (integer, float, etc)
Describe the solution you'd like
Parser.addini method receives a parameter called type that can be any of these string literals:
type: Optional[ "Literal['string', 'paths', 'pathlist', 'args', 'linelist', 'bool']" ] = None,Add the literals (int, float) and have pytest to do the type check and conversion behind the scene.
Alternative Solutions
parser.addini( "my_param", type="string", default="1.0", help="My float param." ) def my_param(request): try: return float(request.config.getini("my_param")) except: return 1.0 #The default value set with default="1.0",With the implementation of this feature, this can be reduced to this;
parser.addini( "my_param", type="float", default="1.0", help="My float param." ) def my_param(request): return request.config.getini("my_param")Additional context