Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use open instead of io.open #389

Merged
merged 1 commit into from Mar 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 2 additions & 3 deletions setup.py
@@ -1,19 +1,18 @@
import io
from setuptools import setup


def read_files(files):
data = []
for file in files:
with io.open(file, encoding='utf-8') as f:
with open(file, encoding='utf-8') as f:
data.append(f.read())
return "\n".join(data)


long_description = read_files(['README.md', 'CHANGELOG.md'])

meta = {}
with io.open('./src/dotenv/version.py', encoding='utf-8') as f:
with open('./src/dotenv/version.py', encoding='utf-8') as f:
exec(f.read(), meta)

setup(
Expand Down
6 changes: 3 additions & 3 deletions src/dotenv/main.py
Expand Up @@ -51,7 +51,7 @@ def __init__(
@contextmanager
def _get_stream(self) -> Iterator[IO[str]]:
if self.dotenv_path and os.path.isfile(self.dotenv_path):
with io.open(self.dotenv_path, encoding=self.encoding) as stream:
with open(self.dotenv_path, encoding=self.encoding) as stream:
yield stream
elif self.stream is not None:
yield self.stream
Expand Down Expand Up @@ -129,10 +129,10 @@ def rewrite(
) -> Iterator[Tuple[IO[str], IO[str]]]:
try:
if not os.path.isfile(path):
with io.open(path, "w+", encoding=encoding) as source:
with open(path, "w+", encoding=encoding) as source:
source.write("")
with tempfile.NamedTemporaryFile(mode="w+", delete=False, encoding=encoding) as dest:
with io.open(path, encoding=encoding) as source:
with open(path, encoding=encoding) as source:
yield (source, dest) # type: ignore
except BaseException:
if os.path.isfile(dest.name):
Expand Down