diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e7734782..005ed8ef 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -14,7 +14,7 @@ repos: hooks: - id: flake8 - repo: https://github.com/asottile/pyupgrade - rev: v2.38.2 + rev: v3.0.0 hooks: - id: pyupgrade - repo: https://github.com/pycqa/isort @@ -23,6 +23,6 @@ repos: - id: isort name: isort (python) - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black diff --git a/docs/conf.py b/docs/conf.py index 831d7c03..854dd1fa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,7 +19,7 @@ # Generate the agglomerated changes (from the CHANGELOG) between fortls # and the fortran-language-server project -with open("../CHANGELOG.md", "r") as f: +with open("../CHANGELOG.md") as f: lns = f.readlines() lns = lns[0 : lns.index("## 1.12.0\n")] diff --git a/fortls/__init__.py b/fortls/__init__.py index ede8a9a4..ad49385e 100644 --- a/fortls/__init__.py +++ b/fortls/__init__.py @@ -1,5 +1,3 @@ -from __future__ import print_function - import json import os import pprint @@ -467,7 +465,7 @@ def debug_server_parser(args): config_exists = os.path.isfile(config_path) if config_exists: try: - with open(config_path, "r") as fhandle: + with open(config_path) as fhandle: config_dict = json.load(fhandle) pp_suffixes = config_dict.get("pp_suffixes", None) pp_defs = config_dict.get("pp_defs", {}) diff --git a/fortls/intrinsics.py b/fortls/intrinsics.py index 1de509df..b29a0397 100644 --- a/fortls/intrinsics.py +++ b/fortls/intrinsics.py @@ -140,7 +140,7 @@ def add_children(json_obj, fort_obj): os.path.dirname(os.path.abspath(__file__)), "statements.json" ) statements = {"var_def": [], "int_stmnts": []} - with open(json_file, "r", encoding="utf-8") as fid: + with open(json_file, encoding="utf-8") as fid: intrin_file = json.load(fid) for key in statements: for name, json_obj in sorted(intrin_file[key].items()): @@ -151,7 +151,7 @@ def add_children(json_obj, fort_obj): os.path.dirname(os.path.abspath(__file__)), "keywords.json" ) keywords = {"var_def": [], "arg": [], "type_mem": [], "vis": [], "param": []} - with open(json_file, "r", encoding="utf-8") as fid: + with open(json_file, encoding="utf-8") as fid: intrin_file = json.load(fid) for key in keywords: for name, json_obj in sorted(intrin_file[key].items()): @@ -162,7 +162,7 @@ def add_children(json_obj, fort_obj): os.path.dirname(os.path.abspath(__file__)), "intrinsic_funs.json" ) int_funs = [] - with open(json_file, "r", encoding="utf-8") as fid: + with open(json_file, encoding="utf-8") as fid: intrin_file = json.load(fid) for name, json_obj in sorted(intrin_file.items()): int_funs.append(create_int_object(name, json_obj, json_obj["type"])) @@ -173,7 +173,7 @@ def add_children(json_obj, fort_obj): os.path.dirname(os.path.abspath(__file__)), "intrinsic_mods.json" ) int_mods = [] - with open(json_file, "r", encoding="utf-8") as fid: + with open(json_file, encoding="utf-8") as fid: intrin_file = json.load(fid) for key, json_obj in intrin_file.items(): fort_obj = create_object(json_obj) diff --git a/fortls/langserver.py b/fortls/langserver.py index 3d34f6ff..7c120089 100644 --- a/fortls/langserver.py +++ b/fortls/langserver.py @@ -1508,7 +1508,7 @@ def _load_config_file(self) -> None: break try: - with open(config_path, "r") as jsonfile: + with open(config_path) as jsonfile: config_dict = json5.load(jsonfile) # Include and Exclude directories diff --git a/fortls/parse_fortran.py b/fortls/parse_fortran.py index 3b6960c4..8f3ba2c4 100644 --- a/fortls/parse_fortran.py +++ b/fortls/parse_fortran.py @@ -866,7 +866,7 @@ def load_from_disk(self) -> tuple[str | None, bool | None]: """ contents: str try: - with open(self.path, "r", encoding="utf-8", errors="replace") as f: + with open(self.path, encoding="utf-8", errors="replace") as f: contents = re.sub(r"\t", r" ", f.read()) except OSError: return "Could not read/decode file", None