Skip to content

Commit

Permalink
removing the dependency on the io module because some environments th…
Browse files Browse the repository at this point in the history
…row an error
  • Loading branch information
FabienArcellier committed Jan 22, 2024
1 parent 162aff7 commit ae478d2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/alfred/lib.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import contextlib
import glob
import io
import os
import sys
from typing import List, Iterator, ContextManager
Expand All @@ -14,7 +13,7 @@
def import_python(python_path: str) -> dict:

module = {"__file__": python_path}
with io.open(python_path, encoding="utf8") as file:
with open(python_path, encoding="utf8") as file:
content = file.read()
try:
code = compile(content, python_path, 'exec')
Expand Down
3 changes: 1 addition & 2 deletions src/alfred/manifest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import io
import os
from typing import Optional, List, Any

Expand Down Expand Up @@ -39,7 +38,7 @@ def lookup(path: Optional[str] = None, search: bool = True) -> AlfredManifest:
alfred_project_dir = lookup_project_dir(path=path, search=search)
alfred_manifest_path = os.path.join(alfred_project_dir, ".alfred.toml")

with io.open(alfred_manifest_path, encoding="utf8") as file:
with open(alfred_manifest_path, encoding="utf8") as file:
alfred_configuration = toml.load(file)
return AlfredManifest(alfred_manifest_path, alfred_configuration)

Expand Down
5 changes: 2 additions & 3 deletions src/alfred/resource.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import io
import os
from typing import Optional

Expand All @@ -24,7 +23,7 @@ def read(resource: str) -> Optional[str]:
if not os.path.isfile(resource_path):
raise ValueError(f'{resource_path} is missing')

with io.open(resource_path, encoding='utf-8') as filep:
with open(resource_path, encoding='utf-8') as filep:
return filep.read()


Expand All @@ -46,6 +45,6 @@ def template(resource: str, variables: dict):
if not os.path.isfile(resource_path):
raise ValueError(f'{resource_path} is missing')

with io.open(resource_path, encoding='utf-8') as filep:
with open(resource_path, encoding='utf-8') as filep:
content = filep.read()
return content.format(**variables)
3 changes: 1 addition & 2 deletions src/alfred/venv_plugins/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
If the parameter venv_poetry_ignore is set in the section project, then the code move on to the next plugin.
"""
import io
import os
import shutil
import subprocess
Expand Down Expand Up @@ -57,7 +56,7 @@ def is_poetry_project(project_dir: str) -> bool:
if os.path.isfile(pyproject_path) is False:
return False

with io.open(pyproject_path, 'r', encoding='utf-8') as pyproject_filep:
with open(pyproject_path, 'r', encoding='utf-8') as pyproject_filep:
try:
pyproject_dict = toml.load(pyproject_filep)
build_system = pyproject_dict.get('build-system', {})
Expand Down

0 comments on commit ae478d2

Please sign in to comment.