From a0b401dec666cdeed1b38481f2057cf6e19396f0 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Mon, 9 Aug 2021 12:20:30 +0300 Subject: [PATCH 1/2] Fixes `tomli` warning about non-binary files https://github.com/hukkin/tomli/blob/eaa381a341d2a39a62680798e4ad4dceb26326a0/tomli/_parser.py#L71-L77 --- mypy/config_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/config_parser.py b/mypy/config_parser.py index d5552186ecc70..132a77cf94f46 100644 --- a/mypy/config_parser.py +++ b/mypy/config_parser.py @@ -168,7 +168,7 @@ def parse_config_file(options: Options, set_strict_flags: Callable[[], None], continue try: if is_toml(config_file): - with open(config_file, encoding="utf-8") as f: + with open(config_file, 'rb', encoding="utf-8") as f: toml_data = tomli.load(f) # Filter down to just mypy relevant toml keys toml_data = toml_data.get('tool', {}) From 3859c342c3c7d591477774bb3a4f5e5bdc9f3a5f Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Mon, 9 Aug 2021 12:21:46 +0300 Subject: [PATCH 2/2] The same for `modulefinder` --- mypy/modulefinder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/modulefinder.py b/mypy/modulefinder.py index 6cebd7db8bc0b..1570a322a6802 100644 --- a/mypy/modulefinder.py +++ b/mypy/modulefinder.py @@ -434,7 +434,7 @@ def _is_compatible_stub_package(self, stub_dir: str) -> bool: if os.path.isfile(metadata_fnam): # Delay import for a possible minor performance win. import tomli - with open(metadata_fnam, 'r', encoding="utf-8") as f: + with open(metadata_fnam, 'rb', encoding="utf-8") as f: metadata = tomli.load(f) if self.python_major_ver == 2: return bool(metadata.get('python2', False))