mirror of
https://github.com/open-telemetry/opentelemetry-python-contrib.git
synced 2025-08-02 19:47:17 +08:00
Added eachdist.py format
command (#487)
This just runs black and isort of the entire repository.
This commit is contained in:
@ -237,6 +237,16 @@ def parse_args(args=None):
|
||||
"releaseargs", nargs=argparse.REMAINDER, help=extraargs_help("pytest")
|
||||
)
|
||||
|
||||
fmtparser = subparsers.add_parser(
|
||||
"format", help="Formats all source code with black and isort.",
|
||||
)
|
||||
fmtparser.set_defaults(func=format_args)
|
||||
fmtparser.add_argument(
|
||||
"--path",
|
||||
required=False,
|
||||
help="Format only this path instead of entire repository",
|
||||
)
|
||||
|
||||
return parser.parse_args(args)
|
||||
|
||||
|
||||
@ -644,6 +654,22 @@ def test_args(args):
|
||||
)
|
||||
|
||||
|
||||
def format_args(args):
|
||||
format_dir = str(find_projectroot())
|
||||
if args.path:
|
||||
format_dir = os.path.join(format_dir, args.path)
|
||||
|
||||
runsubprocess(
|
||||
args.dry_run, ("black", "."), cwd=format_dir, check=True,
|
||||
)
|
||||
runsubprocess(
|
||||
args.dry_run,
|
||||
("isort", "--profile", "black", "."),
|
||||
cwd=format_dir,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
args.func(args)
|
||||
|
Reference in New Issue
Block a user