From 1760897a8c5ea8a9476103e5e3aa773251430d32 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 2 Aug 2021 14:19:49 -0700 Subject: [PATCH] python: Remove default "r" mode for open(). Generated automatically by pyupgrade. Signed-off-by: Anders Kaseorg --- scripts/lib/node_cache.py | 4 ++-- scripts/lib/puppet_cache.py | 4 ++-- scripts/setup/compare-settings-to-template | 2 +- scripts/zulip-puppet-apply | 2 +- zerver/openapi/test_curl_examples.py | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/lib/node_cache.py b/scripts/lib/node_cache.py index 27f7f8c9ba..19a709668f 100644 --- a/scripts/lib/node_cache.py +++ b/scripts/lib/node_cache.py @@ -34,11 +34,11 @@ def generate_sha1sum_node_modules( PACKAGE_JSON_FILE_PATH = os.path.join(setup_dir, "package.json") YARN_LOCK_FILE_PATH = os.path.join(setup_dir, "yarn.lock") data: Dict[str, object] = {} - with open(PACKAGE_JSON_FILE_PATH, "r") as f: + with open(PACKAGE_JSON_FILE_PATH) as f: data[PACKAGE_JSON_FILE_PATH] = f.read().strip() if os.path.exists(YARN_LOCK_FILE_PATH): # For backwards compatibility, we can't assume yarn.lock exists - with open(YARN_LOCK_FILE_PATH, "r") as f: + with open(YARN_LOCK_FILE_PATH) as f: data[YARN_LOCK_FILE_PATH] = f.read().strip() with open(YARN_PACKAGE_JSON) as f: data["yarn-package-version"] = json.load(f)["version"] diff --git a/scripts/lib/puppet_cache.py b/scripts/lib/puppet_cache.py index 7440f8f7a0..dc1cd50907 100644 --- a/scripts/lib/puppet_cache.py +++ b/scripts/lib/puppet_cache.py @@ -18,7 +18,7 @@ PUPPET_THIRDPARTY = os.path.join(PUPPET_MODULES_CACHE_PATH, "current") def generate_sha1sum_puppet_modules() -> str: data = {} - with open(PUPPET_DEPS_FILE_PATH, "r") as fb: + with open(PUPPET_DEPS_FILE_PATH) as fb: data["deps.yaml"] = fb.read().strip() data["puppet-version"] = subprocess.check_output( # This is 10x faster than `puppet --version` @@ -57,7 +57,7 @@ def do_puppet_module_install( puppet_env["RUBYOPT"] = "-W0" os.makedirs(target_path, exist_ok=True) - with open(PUPPET_DEPS_FILE_PATH, "r") as yaml_file: + with open(PUPPET_DEPS_FILE_PATH) as yaml_file: deps = yaml.safe_load(yaml_file) for module, version in deps.items(): run( diff --git a/scripts/setup/compare-settings-to-template b/scripts/setup/compare-settings-to-template index fe662478c4..ced009cc23 100755 --- a/scripts/setup/compare-settings-to-template +++ b/scripts/setup/compare-settings-to-template @@ -17,7 +17,7 @@ if len(sys.argv) >= 2: current_path = sys.argv[1] print(f"Reading current configuration from {current_path}...") -with open(current_path, "r") as f: +with open(current_path) as f: current_contents = f.read() import requests diff --git a/scripts/zulip-puppet-apply b/scripts/zulip-puppet-apply index 9767604838..26c97e82a6 100755 --- a/scripts/zulip-puppet-apply +++ b/scripts/zulip-puppet-apply @@ -75,7 +75,7 @@ if not args.noop and not args.force: env=puppet_env, ) - with open(lastrun_file.name, "r") as lastrun: + with open(lastrun_file.name) as lastrun: lastrun_data = yaml.safe_load(lastrun) if lastrun_data.get("resources", {}).get("out_of_sync", 0) == 0: sys.exit(0) diff --git a/zerver/openapi/test_curl_examples.py b/zerver/openapi/test_curl_examples.py index 1b6cd04194..9753594b10 100644 --- a/zerver/openapi/test_curl_examples.py +++ b/zerver/openapi/test_curl_examples.py @@ -41,7 +41,7 @@ def test_generated_curl_examples_for_success(client: Client) -> None: rest_endpoints_path = os.path.join( settings.DEPLOY_ROOT, "templates/zerver/help/include/rest-endpoints.md" ) - rest_endpoints_raw = open(rest_endpoints_path, "r").read() + rest_endpoints_raw = open(rest_endpoints_path).read() ENDPOINT_REGEXP = re.compile(r"/api/\s*(.*?)\)") endpoint_list = sorted(set(re.findall(ENDPOINT_REGEXP, rest_endpoints_raw))) @@ -51,7 +51,7 @@ def test_generated_curl_examples_for_success(client: Client) -> None: curl_commands_to_test = [] if os.path.exists(file_name): - f = open(file_name, "r") + f = open(file_name) for line in f: # A typical example from the Markdown source looks like this: # {generate_code_example(curl, ...}