Skip to content

Commit

Permalink
Disable universal newlines when reading TOML (#10893)
Browse files Browse the repository at this point in the history
* Disable universal newlines when reading TOML

* Update mypy/modulefinder.py

Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>

* Update mypy/config_parser.py

Co-authored-by: Taneli Hukkinen <3275109+hukkin@users.noreply.github.com>

Co-authored-by: Ivan Levkivskyi <levkivskyi@gmail.com>
  • Loading branch information
hukkin and ilevkivskyi committed Dec 1, 2021
1 parent 3027cd6 commit 02d6c7a
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mypy-requirements.txt
@@ -1,4 +1,4 @@
typing_extensions>=3.10
mypy_extensions>=0.4.3,<0.5.0
typed_ast>=1.4.0,<2; python_version<'3.8'
tomli>=1.1.0,<1.2.0
tomli>=1.1.0,<2.0.0
2 changes: 1 addition & 1 deletion mypy/config_parser.py
Expand Up @@ -172,7 +172,7 @@ def parse_config_file(options: Options, set_strict_flags: Callable[[], None],
try:
if is_toml(config_file):
with open(config_file, encoding="utf-8") as f:
toml_data = tomli.load(f)
toml_data = tomli.loads(f.read())
# Filter down to just mypy relevant toml keys
toml_data = toml_data.get('tool', {})
if 'mypy' not in toml_data:
Expand Down
4 changes: 2 additions & 2 deletions mypy/modulefinder.py
Expand Up @@ -451,8 +451,8 @@ 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:
metadata = tomli.load(f)
with open(metadata_fnam, encoding="utf-8") as f:
metadata = tomli.loads(f.read())
if self.python_major_ver == 2:
return bool(metadata.get('python2', False))
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -195,7 +195,7 @@ def run(self):
install_requires=["typed_ast >= 1.4.0, < 2; python_version<'3.8'",
'typing_extensions>=3.10',
'mypy_extensions >= 0.4.3, < 0.5.0',
'tomli>=1.1.0,<1.2.0',
'tomli>=1.1.0,<2.0.0',
],
# Same here.
extras_require={'dmypy': 'psutil >= 4.0', 'python2': 'typed_ast >= 1.4.0, < 2'},
Expand Down

0 comments on commit 02d6c7a

Please sign in to comment.