mypy: zulip_bots: Fix errors in generate_manifest.py.
This commit is contained in:
parent
fe6deb2e03
commit
3d282a12a7
|
@ -22,7 +22,6 @@ exclude = """
|
||||||
zulip/integrations/perforce/git_p4.py
|
zulip/integrations/perforce/git_p4.py
|
||||||
|
|
||||||
zulip_bots/zulip_bots/bots
|
zulip_bots/zulip_bots/bots
|
||||||
zulip_bots/generate_manifest.py
|
|
||||||
zulip_bots/setup.py
|
zulip_bots/setup.py
|
||||||
zulip_bots/zulip_bots/lib.py
|
zulip_bots/zulip_bots/lib.py
|
||||||
zulip_bots/zulip_bots/provision.py
|
zulip_bots/zulip_bots/provision.py
|
||||||
|
|
|
@ -5,6 +5,7 @@ import os
|
||||||
import glob
|
import glob
|
||||||
import distutils.cmd
|
import distutils.cmd
|
||||||
import distutils.log
|
import distutils.log
|
||||||
|
from typing import IO, Iterator
|
||||||
|
|
||||||
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||||
BOTS_DIR = os.path.normpath(os.path.join(CURRENT_DIR, 'zulip_bots', 'bots'))
|
BOTS_DIR = os.path.normpath(os.path.join(CURRENT_DIR, 'zulip_bots', 'bots'))
|
||||||
|
@ -21,27 +22,30 @@ class GenerateManifest(distutils.cmd.Command):
|
||||||
]
|
]
|
||||||
|
|
||||||
def initialize_options(self):
|
def initialize_options(self):
|
||||||
|
# type: () -> None
|
||||||
self.release = False
|
self.release = False
|
||||||
|
|
||||||
def finalize_options(self):
|
def finalize_options(self):
|
||||||
|
# type: () -> None
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
# type: () -> None
|
||||||
if self.release:
|
if self.release:
|
||||||
generate_release_manifest()
|
generate_release_manifest()
|
||||||
self.announce(
|
self.announce( # type: ignore # error: "GenerateManifest" has no attribute "announce"
|
||||||
'Generating a MANIFEST for a PyPA release of zulip_bots.',
|
'Generating a MANIFEST for a PyPA release of zulip_bots.',
|
||||||
level=distutils.log.INFO
|
level=distutils.log.INFO # type: ignore # error: Module has no attribute "INFO"
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
generate_dev_manifest()
|
generate_dev_manifest()
|
||||||
self.announce(
|
self.announce( # type: ignore
|
||||||
'Generating a MANIFEST for zulip_bots\' development.',
|
'Generating a MANIFEST for zulip_bots\' development.',
|
||||||
level=distutils.log.INFO
|
level=distutils.log.INFO # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_test_fixtures():
|
def get_test_fixtures():
|
||||||
# type: () -> List[str]
|
# type: () -> Iterator[str]
|
||||||
glob_pattern = os.path.join(BOTS_DIR, '*', 'fixtures', '*.json')
|
glob_pattern = os.path.join(BOTS_DIR, '*', 'fixtures', '*.json')
|
||||||
fixtures_paths = map(
|
fixtures_paths = map(
|
||||||
lambda fp: os.path.join(*fp.split(os.path.sep)[-5:]).replace(os.path.sep, '/'),
|
lambda fp: os.path.join(*fp.split(os.path.sep)[-5:]).replace(os.path.sep, '/'),
|
||||||
|
@ -50,7 +54,7 @@ def get_test_fixtures():
|
||||||
return fixtures_paths
|
return fixtures_paths
|
||||||
|
|
||||||
def get_logos():
|
def get_logos():
|
||||||
# type: () -> List[str]
|
# type: () -> Iterator[str]
|
||||||
glob_pattern = os.path.join(BOTS_DIR, '*', 'logo.*')
|
glob_pattern = os.path.join(BOTS_DIR, '*', 'logo.*')
|
||||||
logo_paths = map(
|
logo_paths = map(
|
||||||
lambda fp: os.path.join(*fp.split(os.path.sep)[-4:]).replace(os.path.sep, '/'),
|
lambda fp: os.path.join(*fp.split(os.path.sep)[-4:]).replace(os.path.sep, '/'),
|
||||||
|
@ -59,7 +63,7 @@ def get_logos():
|
||||||
return logo_paths
|
return logo_paths
|
||||||
|
|
||||||
def get_docs():
|
def get_docs():
|
||||||
# type: () -> List[str]
|
# type: () -> Iterator[str]
|
||||||
glob_pattern = os.path.join(BOTS_DIR, '*', 'doc.md')
|
glob_pattern = os.path.join(BOTS_DIR, '*', 'doc.md')
|
||||||
doc_paths = map(
|
doc_paths = map(
|
||||||
lambda fp: os.path.join(*fp.split(os.path.sep)[-4:]).replace(os.path.sep, '/'),
|
lambda fp: os.path.join(*fp.split(os.path.sep)[-4:]).replace(os.path.sep, '/'),
|
||||||
|
@ -68,7 +72,7 @@ def get_docs():
|
||||||
return doc_paths
|
return doc_paths
|
||||||
|
|
||||||
def get_assets():
|
def get_assets():
|
||||||
# type: () -> List[str]
|
# type: () -> Iterator[str]
|
||||||
glob_pattern = os.path.join(BOTS_DIR, '*', 'assets', '*')
|
glob_pattern = os.path.join(BOTS_DIR, '*', 'assets', '*')
|
||||||
assets_files = map(
|
assets_files = map(
|
||||||
lambda fp: os.path.join(*fp.split(os.path.sep)[-5:]).replace(os.path.sep, '/'),
|
lambda fp: os.path.join(*fp.split(os.path.sep)[-5:]).replace(os.path.sep, '/'),
|
||||||
|
@ -77,7 +81,7 @@ def get_assets():
|
||||||
return assets_files
|
return assets_files
|
||||||
|
|
||||||
def generate_and_write(filepaths, file_obj):
|
def generate_and_write(filepaths, file_obj):
|
||||||
# type: () -> None
|
# type: (Iterator[str], IO[str]) -> None
|
||||||
template = 'include {line}\n'
|
template = 'include {line}\n'
|
||||||
lines = map(lambda line: template.format(line=line), filepaths)
|
lines = map(lambda line: template.format(line=line), filepaths)
|
||||||
|
|
||||||
|
@ -99,6 +103,7 @@ def generate_release_manifest():
|
||||||
generate_and_write(get_assets(), fp)
|
generate_and_write(get_assets(), fp)
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
|
# type: () -> argparse.Namespace
|
||||||
usage = """
|
usage = """
|
||||||
To generate a MANIFEST.in for a PyPA release, run:
|
To generate a MANIFEST.in for a PyPA release, run:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue