Skip to content

Commit 94e24ba

Browse files
committed
Changed to check if ConVar is a valid ConVar.
1 parent 96145c7 commit 94e24ba

File tree

1 file changed

+8
-7
lines changed
  • addons/source-python/packages/source-python/cvars

1 file changed

+8
-7
lines changed

addons/source-python/packages/source-python/cvars/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ def __init__(self, *convars):
4848

4949
_convars = []
5050
for convar in convars:
51-
if not isinstance(convar, (str, ConVar)):
51+
if isinstance(convar, str):
52+
convar_name = convar
53+
elif isinstance(convar, ConVar):
54+
convar_name = convar.name
55+
else:
5256
raise ValueError('Given convar is not ConVar or ConVar name.')
5357

54-
elif isinstance(convar, str):
55-
convar_name = convar
56-
convar = cvar.find_var(convar_name)
57-
if convar is None:
58-
raise ValueError(
59-
f'"{convar_name}" is not a valid ConVar name.')
58+
convar = cvar.find_var(convar_name)
59+
if convar is None:
60+
raise ValueError(f'"{convar_name}" is not a valid ConVar.')
6061

6162
_convars.append(convar)
6263

0 commit comments

Comments
 (0)