File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -437,16 +437,16 @@ def subauthority_component_is_valid(
437
437
elif component != "port" :
438
438
return True
439
439
440
- try :
441
- # fmt: off
442
- port = int (subauthority_dict ["port" ]) # pyright: ignore[reportArgumentType] # noqa: E501 # Guarded by "except TypeError".
443
- # fmt: on
444
- except TypeError :
445
- # If the port wasn't provided it'll be None and int(None) raises a
446
- # TypeError
440
+ port = subauthority_dict ["port" ]
441
+
442
+ if port is None :
447
443
return True
448
444
449
- return 0 <= port <= 65535
445
+ # We know it has to have fewer than 6 digits if it exists.
446
+ if not (port .isdigit () and len (port ) < 6 ):
447
+ return False
448
+
449
+ return 0 <= int (port ) <= 65535
450
450
451
451
452
452
def ensure_components_are_valid (
You can’t perform that action at this time.
0 commit comments