Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
python: Remove default "r" mode for open().
Anders Kaseorg1760897a8c5e
diff --git a/scripts/lib/node_cache.py b/scripts/lib/node_cache.pyindex 27f7f8c9ba7..19a709668ff 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.pyindex 7440f8f7a06..dc1cd50907a 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-templateindex fe662478c41..ced009cc232 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 requestsdiff --git a/scripts/zulip-puppet-apply b/scripts/zulip-puppet-applyindex 97676048387..26c97e82a62 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.pyindex 1b6cd04194c..9753594b10b 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, ...}