Use union syntax for isinstance checks (UP038 rule in Ruff) (#2829)
This commit is contained in:
parent
b61b5c82fa
commit
44f4bc8612
|
|
@ -70,9 +70,9 @@ def jsonify(obj: Any, safe: bool = True) -> Any:
|
|||
# a dictionary representation of the object so that it can be
|
||||
# processed by the json library.
|
||||
return jsonify(obj.json(), safe)
|
||||
if isinstance(obj, (datetime, date)):
|
||||
if isinstance(obj, datetime | date):
|
||||
return obj.isoformat()
|
||||
if isinstance(obj, (list, set, tuple)):
|
||||
if isinstance(obj, list | set | tuple):
|
||||
return [jsonify(item, safe) for item in obj]
|
||||
if isinstance(obj, pathlib.Path):
|
||||
return str(obj)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class Selector:
|
|||
def is_empty(self) -> bool:
|
||||
if self.current_selection is None:
|
||||
return True
|
||||
elif isinstance(self.current_selection, (str, list, dict)) and len(self.current_selection) == 0:
|
||||
elif isinstance(self.current_selection, str | list | dict) and len(self.current_selection) == 0:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ class FormattedOutput:
|
|||
if '!' in key:
|
||||
value = '*' * len(value)
|
||||
|
||||
if isinstance(value, (int, float)) or (isinstance(value, str) and value.isnumeric()):
|
||||
if isinstance(value, int | float) or (isinstance(value, str) and value.isnumeric()):
|
||||
obj_data.append(unicode_rjust(str(value), width))
|
||||
else:
|
||||
obj_data.append(unicode_ljust(str(value), width))
|
||||
|
|
|
|||
Loading…
Reference in New Issue