Skip to content

Commit

Permalink
Use contextlib.nullcontext (Python 3.7+)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Dec 12, 2024
1 parent 451551d commit 297c66c
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions amodem/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# PYTHON_ARGCOMPLETE_OK
import argparse
import contextlib
import logging
import os
import sys
Expand Down Expand Up @@ -183,14 +184,6 @@ def create_parser(description, interface_factory):
return p


class _Dummy:
def __enter__(self):
return self

def __exit__(self, *args):
pass


def _version():
return pkg_resources.require('amodem')[0].version

Expand Down Expand Up @@ -240,11 +233,11 @@ def interface_factory():
from . import alsa # pylint: disable=import-outside-toplevel
interface = alsa.Interface(config)
elif args.audio_library == '-':
interface = _Dummy() # manually disable PortAudio
interface = contextlib.nullcontext() # manually disable PortAudio
elif args.command == 'send' and args.output is not None:
interface = _Dummy() # redirected output
interface = contextlib.nullcontext() # redirected output
elif args.command == 'recv' and args.input is not None:
interface = _Dummy() # redirected input
interface = contextlib.nullcontext() # redirected input
else:
interface = audio.Interface(config)
interface.load(args.audio_library)
Expand Down

0 comments on commit 297c66c

Please sign in to comment.