Added `eachdist.py format` command (#487)
This just runs black and isort of the entire repository.
This commit is contained in:
		
							parent
							
								
									9199e3cb3e
								
							
						
					
					
						commit
						4966590d6c
					
				|  | @ -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) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue