Skip to content

Commit 706e1dc

Browse files
committed
{Core} Remove double definition of 'is_guid'
1 parent 8540590 commit 706e1dc

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

  • src/azure-cli-core/azure/cli/core

src/azure-cli-core/azure/cli/core/util.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,9 +1235,15 @@ def is_guid(guid):
12351235
try:
12361236
uuid.UUID(guid)
12371237
return True
1238-
except ValueError:
1238+
except (ValueError, TypeError):
12391239
return False
12401240

1241+
def assert_guid(guid, name=None):
1242+
if not is_guid(guid):
1243+
if name:
1244+
raise CLIError("{} must be a GUID.".format(name))
1245+
raise CLIError("{} is not a GUID.".format(guid))
1246+
12411247

12421248
def handle_version_update():
12431249
"""Clean up information in local files that may be invalidated
@@ -1353,17 +1359,3 @@ def should_encrypt_token_cache(cli_ctx):
13531359
encrypt = cli_ctx.config.getboolean('core', 'encrypt_token_cache', fallback=fallback)
13541360

13551361
return encrypt
1356-
1357-
def is_guid(guid):
1358-
import uuid
1359-
try:
1360-
uuid.UUID(guid)
1361-
return True
1362-
except (ValueError, TypeError):
1363-
return False
1364-
1365-
def assert_guid(guid, name=None):
1366-
if not is_guid(guid):
1367-
if name:
1368-
raise CLIError("{} must be a GUID.".format(name))
1369-
raise CLIError("{} is not a GUID.".format(guid))

0 commit comments

Comments
 (0)