Skip to content

Commit 30c0f48

Browse files
authored
pydrive2: use isinstance() instead of type() (#291)
Looks like this was an anti pattern that stuck around from some early days. Fixes iterative/dvc-gdrive#31
1 parent 53ee84c commit 30c0f48

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pydrive2/files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def GetContentString(
285285
"""
286286
if (
287287
self.content is None
288-
or type(self.content) is not io.BytesIO
288+
or not isinstance(self.content, io.BytesIO)
289289
or self.has_bom == remove_bom
290290
):
291291
self.FetchContent(mimetype, remove_bom)

pydrive2/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ def _ValidateSettingsElement(data, struct, key):
167167
else:
168168
data[key] = default
169169
# If data exists, Check type of the data
170-
elif type(value) is not data_type:
170+
elif not isinstance(value, data_type):
171171
raise InvalidConfigError(f"Setting {key} should be type {data_type}")
172172
# If type of this data is dict, check if structure of the data is valid.
173173
if data_type is dict:
174174
_ValidateSettingsStruct(data[key], struct[key]["struct"])
175175
# If type of this data is list, check if all values in the list is valid.
176176
elif data_type is list:
177177
for element in data[key]:
178-
if type(element) is not struct[key]["struct"]:
178+
if not isinstance(element, struct[key]["struct"]):
179179
raise InvalidConfigError(
180180
"Setting %s should be list of %s"
181181
% (key, struct[key]["struct"])

0 commit comments

Comments
 (0)