Skip to content

Commit

Permalink
remove set_usage()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanghaibao committed May 8, 2024
1 parent 06ca1aa commit 21b8708
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions jcvi/apps/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import sys
import time

from argparse import ArgumentParser, SUPPRESS
from collections.abc import Iterable
from configparser import (
ConfigParser,
Expand All @@ -20,14 +21,13 @@
NoSectionError,
ParsingError,
)

from argparse import ArgumentParser, SUPPRESS
from http.client import HTTPSConnection
from socket import gethostname
from subprocess import CalledProcessError, PIPE, call, check_output
from time import ctime
from typing import Any, Collection, List, Optional, Tuple, Union
from urllib.parse import urlencode

from natsort import natsorted
from rich.console import Console
from rich.logging import RichHandler
Expand Down Expand Up @@ -277,7 +277,7 @@ def set_outfile(self, outfile: Optional[str] = "stdout"):
"""
self.add_argument("-o", "--outfile", default=outfile, help="Outfile name")

def set_outdir(self, outdir="."):
def set_outdir(self, outdir: Optional[str] = "."):
self.add_argument("--outdir", default=outdir, help="Specify output directory")

def set_email(self):
Expand Down Expand Up @@ -735,7 +735,7 @@ def set_pairs(self):
part, e.g. /1, /2, or .f, .r, default behavior is to truncate until last
char.
"""
self.set_usage(self.set_pairs.__doc__)
self.usage = self.set_pairs.__doc__

self.add_argument(
"--pairsfile", default=None, help="Write valid pairs to pairsfile"
Expand Down Expand Up @@ -2225,7 +2225,7 @@ def inspect(object):
print("{}: {}".format(k, details), file=sys.stderr)


def sample_N(a: Collection[Any], N: int, seed: Optional[int] = None) -> List[Any]:
def sample_N(a: Collection, N: int, seed: Optional[int] = None) -> List:
"""
When size of N is > size of a, random.sample() will emit an error:
ValueError: sample larger than population
Expand Down
8 changes: 4 additions & 4 deletions jcvi/apps/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def ensembl(args):

valid_species = [x for x in ls_ftp(fasta_url) if "." not in x]
doc = "\n".join((ensembl.__doc__, tile(valid_species)))
p.set_usage(doc)
p.usage = doc

if len(args) != 1:
sys.exit(not p.print_help())
Expand Down Expand Up @@ -273,15 +273,15 @@ def phytozome(args):
downloader=downloader,
)
g = GlobusXMLParser(directory_listing)
except:
except Exception as _:
logger.error("Error downloading directory listing ... cleaning up")
cleanup(directory_listing, cookies)
sys.exit(1)

genomes = g.get_genomes()
valid_species = genomes.keys()
species_tile = tile(valid_species)
p.set_usage("\n".join((phytozome.__doc__, species_tile)))
p.usage = "\n".join((phytozome.__doc__, species_tile))

if len(args) != 1:
sys.exit(not p.print_help())
Expand Down Expand Up @@ -383,7 +383,7 @@ def phytozome9(args):
valid_species = [x for x in ls_ftp(url) if "." not in x]

doc = "\n".join((phytozome9.__doc__, tile(valid_species)))
p.set_usage(doc)
p.usage = doc

if len(args) != 1:
sys.exit(not p.print_help())
Expand Down

0 comments on commit 21b8708

Please sign in to comment.