Skip to content
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
5 changes: 2 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ confidence=
disable=arguments-renamed, # more readable and clear
bad-continuation, bad-whitespace, # differences of opinion with black
consider-using-f-string, # unnecesary to convert all str.format() to f strings
consider-using-with, # TODO: investigate / re-enable
consider-using-with, # too verbose, not all resource-allocating operations should have `with`
docstring-first-line-empty, # docstrings are more readable
duplicate-code, # too verbose
fixme, # avoid that to do annotations show up as warnings
Expand All @@ -78,7 +78,7 @@ disable=arguments-renamed, # more readable and clear
no-member, # false positives when variable from external function
no-self-use, # too verbose
protected-access, # we don't strictly follow the public vs. private convention
raise-missing-from, # TODO: investigate / re-enable
raise-missing-from, # not every exception needs `from`, adding `from None` is too verbose
too-few-public-methods, # too verbose
too-many-ancestors, # too verbose
too-many-arguments, # too verbose
Expand All @@ -90,7 +90,6 @@ disable=arguments-renamed, # more readable and clear
too-many-public-methods, # too verbose
too-many-statements, # too verbose
unnecessary-pass, # allow for methods with just "pass", for clarity
unspecified-encoding, # TODO: investigate / re-enable

# Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option
Expand Down
12 changes: 6 additions & 6 deletions qiskit_ibm_runtime/accounts/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def save_config(filename: str, name: str, config: dict, overwrite: bool) -> None
logger.debug("Save configuration data for '%s' in '%s'", name, filename)
_ensure_file_exists(filename)

with open(filename, mode="r") as json_in:
with open(filename, mode="r", encoding="utf-8") as json_in:
data = json.load(json_in)

if data.get(name) and not overwrite:
Expand All @@ -35,7 +35,7 @@ def save_config(filename: str, name: str, config: dict, overwrite: bool) -> None
f"Set overwrite=True to overwrite."
)

with open(filename, mode="w") as json_out:
with open(filename, mode="w", encoding="utf-8") as json_out:
data[name] = config
json.dump(data, json_out, sort_keys=True, indent=4)

Expand All @@ -48,7 +48,7 @@ def read_config(
logger.debug("Read configuration data for '%s' from '%s'", name, filename)
_ensure_file_exists(filename)

with open(filename) as json_file:
with open(filename, encoding="utf-8") as json_file:
data = json.load(json_file)
if name is None:
return data
Expand All @@ -67,11 +67,11 @@ def delete_config(
logger.debug("Delete configuration data for '%s' from '%s'", name, filename)

_ensure_file_exists(filename)
with open(filename, mode="r") as json_in:
with open(filename, mode="r", encoding="utf-8") as json_in:
data = json.load(json_in)

if name in data:
with open(filename, mode="w") as json_out:
with open(filename, mode="w", encoding="utf-8") as json_out:
del data[name]
json.dump(data, json_out, sort_keys=True, indent=4)
return True
Expand All @@ -87,5 +87,5 @@ def _ensure_file_exists(filename: str, initial_content: str = "{}") -> None:
os.makedirs(os.path.dirname(filename), exist_ok=True)

# initialize file
with open(filename, mode="w") as json_file:
with open(filename, mode="w", encoding="utf-8") as json_file:
json_file.write(initial_content)
6 changes: 3 additions & 3 deletions qiskit_ibm_runtime/ibm_runtime_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,7 +925,7 @@ def upload_program(

if "def main(" not in data:
# This is the program file
with open(data, "r") as file:
with open(data, "r", encoding="utf-8") as file:
data = file.read()

try:
Expand Down Expand Up @@ -957,7 +957,7 @@ def _read_metadata(self, metadata: Optional[Union[Dict, str]] = None) -> Dict:
upd_metadata: dict = {}
if metadata is not None:
if isinstance(metadata, str):
with open(metadata, "r") as file:
with open(metadata, "r", encoding="utf-8") as file:
upd_metadata = json.load(file)
else:
upd_metadata = metadata
Expand Down Expand Up @@ -1013,7 +1013,7 @@ def update_program(
if data:
if "def main(" not in data:
# This is the program file
with open(data, "r") as file:
with open(data, "r", encoding="utf-8") as file:
data = file.read()
data = to_base64_string(data)

Expand Down
2 changes: 1 addition & 1 deletion qiskit_ibm_runtime/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def git_version() -> str:
return git_revision


with open(os.path.join(ROOT_DIR, "VERSION.txt"), "r") as version_file:
with open(os.path.join(ROOT_DIR, "VERSION.txt"), "r", encoding="utf-8") as version_file:
VERSION = version_file.read().strip()


Expand Down
2 changes: 1 addition & 1 deletion test/test_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def test_log_file(self):
)

# Assert the messages were logged.
with open(temp_log_file.name) as file_:
with open(temp_log_file.name, encoding="utf-8") as file_:
content_as_str = file_.read()

# Check whether the appropriate substrings are in the file.
Expand Down
2 changes: 1 addition & 1 deletion test/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def _run_notebook(filename):

# Open the notebook.
file_path = os.path.dirname(os.path.abspath(filename))
with open(filename) as file_:
with open(filename, encoding="utf-8") as file_:
notebook = nbformat.read(file_, as_version=4)

with warnings.catch_warnings():
Expand Down