Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pydrive2: use isinstance() instead of type() #291

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pydrive2/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def GetContentString(
"""
if (
self.content is None
or type(self.content) is not io.BytesIO
or not isinstance(self.content, io.BytesIO)
or self.has_bom == remove_bom
):
self.FetchContent(mimetype, remove_bom)
Expand Down
4 changes: 2 additions & 2 deletions pydrive2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,15 @@ def _ValidateSettingsElement(data, struct, key):
else:
data[key] = default
# If data exists, Check type of the data
elif type(value) is not data_type:
elif not isinstance(value, data_type):
raise InvalidConfigError(f"Setting {key} should be type {data_type}")
# If type of this data is dict, check if structure of the data is valid.
if data_type is dict:
_ValidateSettingsStruct(data[key], struct[key]["struct"])
# If type of this data is list, check if all values in the list is valid.
elif data_type is list:
for element in data[key]:
if type(element) is not struct[key]["struct"]:
if not isinstance(element, struct[key]["struct"]):
raise InvalidConfigError(
"Setting %s should be list of %s"
% (key, struct[key]["struct"])
Expand Down