Skip to content

Commit

Permalink
Use open instead of io.open
Browse files Browse the repository at this point in the history
  • Loading branch information
rabinadk1 authored and bbc2 committed Mar 25, 2022
1 parent 65dfa71 commit 07a2fa1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit 07a2fa1

Please sign in to comment.