mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-04-16 02:21:46 +04:00
Default to UTF-8 encoding in open() calls
This commit is contained in:
parent
1be4e4f82e
commit
e272c219fd
8 changed files with 26 additions and 18 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
import contextlib
|
||||
import errno
|
||||
import functools
|
||||
import io
|
||||
import os.path
|
||||
import shutil
|
||||
import stat
|
||||
|
|
@ -16,6 +17,14 @@ from pre_commit import five
|
|||
from pre_commit import parse_shebang
|
||||
|
||||
|
||||
def open(*args, **kwargs):
|
||||
"""Some strange interaction with python2, osx, and vscode makes default
|
||||
encoding detection go wrong. See #519
|
||||
"""
|
||||
kwargs.setdefault('encoding', 'UTF-8')
|
||||
return io.open(*args, **kwargs)
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def cwd(path):
|
||||
original_cwd = os.getcwd()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue