Skip to content

Commit

Permalink
Drop support for xopen v1
Browse files Browse the repository at this point in the history
Following through with deprecation to simplify the code.
  • Loading branch information
victorlin committed Dec 5, 2024
1 parent e90383b commit a9645c1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
2 changes: 1 addition & 1 deletion DEPRECATED.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ available for backwards compatibility, but should not be used in new code.

## `xopen` major version 1

*Deprecated in version 25.1.0 (July 2024). Planned for removal November 2024 or after.*
*Deprecated in version 25.1.0 (July 2024). Removed in version 27.0.0 (December 2024).*

## `augur parse` preference of `name` over `strain` as the sequence ID field

Expand Down
16 changes: 2 additions & 14 deletions augur/io/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,9 @@
from contextlib import contextmanager
from io import IOBase
from textwrap import dedent
from xopen import xopen
from xopen import xopen, _PipedCompressionProgram
from augur.errors import AugurError

# Workaround to maintain compatibility with both xopen v1 and v2
# Around November 2024, we shall drop support for xopen v1
# by removing the try-except block and using
# _PipedCompressionProgram directly
try:
from xopen import _PipedCompressionProgram as PipedCompressionReader
from xopen import _PipedCompressionProgram as PipedCompressionWriter
except ImportError:
from xopen import ( # type: ignore[attr-defined, no-redef]
PipedCompressionReader,
PipedCompressionWriter,
)

ENCODING = "utf-8"

Expand Down Expand Up @@ -63,7 +51,7 @@ def open_file(path_or_buffer, mode="r", **kwargs):
Try re-saving the file using the {e.encoding!r} encoding."""))


elif isinstance(path_or_buffer, (IOBase, PipedCompressionReader, PipedCompressionWriter)):
elif isinstance(path_or_buffer, (IOBase, _PipedCompressionProgram)):
yield path_or_buffer

else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"pyfastx >=1.0.0, <3.0",
"python_calamine >=0.2.0",
"scipy ==1.*",
"xopen[zstd] >=1.7.0, <3" # TODO: Deprecated, remove v1 support around November 2024
"xopen[zstd] >=2.0.0, <3"
],
extras_require = {
'dev': [
Expand Down

0 comments on commit a9645c1

Please sign in to comment.