index
int64
0
50.7k
project_path
stringclasses
279 values
completion_path
stringlengths
57
199
signature_postion
stringlengths
3
11
class_position
stringlengths
3
11
function_name
stringlengths
1
62
class_name
stringlengths
0
55
body_position
stringlengths
3
11
body_position_with_comments
stringlengths
3
11
masked_class
stringlengths
14
8.32k
masked_class_with_comment
stringlengths
14
8.32k
func_body
stringlengths
9
6.72k
func_body_with_comment
stringlengths
9
6.72k
len_func_body
int64
1
643
len_input
int64
10
2.02k
len_output
int64
4
1.9k
total
int64
20
2.05k
file_code
stringlengths
14
442k
file_code_with_comment
stringlengths
14
442k
26,644
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/bool/tutorial003_an.py
5,6
1,14
main
6,12
6,12
import typer from typing_extensions import Annotated def main(force: Annotated[bool, typer.Option("--force/--no-force", "-f/-F")] = False): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(force: Annotated[bool, typer.Option("--force/--no-force", "-f/-F")] = False): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if force: print("Forcing operation") else: print("Not forcing")
if force: print("Forcing operation") else: print("Not forcing")
7
78
32
110
import typer from typing_extensions import Annotated def main(force: Annotated[bool, typer.Option("--force/--no-force", "-f/-F")] = False): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(force: Annotated[bool, typer.Option("--force/--no-force", "-f/-F")] = False): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,645
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/bool/tutorial004.py
4,5
1,13
main
5,11
5,11
import typer def main(in_prod: bool = typer.Option(True, " /--demo", " /-d")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(in_prod: bool = typer.Option(True, " /--demo", " /-d")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if in_prod: print("Running in production") else: print("Running demo")
if in_prod: print("Running in production") else: print("Running demo")
8
65
34
99
import typer def main(in_prod: bool = typer.Option(True, " /--demo", " /-d")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(in_prod: bool = typer.Option(True, " /--demo", " /-d")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,646
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/bool/tutorial004_an.py
5,6
1,14
main
6,12
6,12
import typer from typing_extensions import Annotated def main(in_prod: Annotated[bool, typer.Option(" /--demo", " /-d")] = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(in_prod: Annotated[bool, typer.Option(" /--demo", " /-d")] = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if in_prod: print("Running in production") else: print("Running demo")
if in_prod: print("Running in production") else: print("Running demo")
8
77
34
111
import typer from typing_extensions import Annotated def main(in_prod: Annotated[bool, typer.Option(" /--demo", " /-d")] = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(in_prod: Annotated[bool, typer.Option(" /--demo", " /-d")] = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,647
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/custom_types/tutorial001.py
12,13
1,26
parse_custom_class
13,16
13,16
import typer class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): FILL_FUNC_BODYdef main( custom_arg: CustomClass = typer.Argument(parser=parse_custom_class), custom_o...
import typer class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): FILL_FUNC_BODYdef main( custom_arg: CustomClass = typer.Argument(parser=parse_custom_class), custom_o...
return CustomClass(value * 2)
return CustomClass(value * 2)
4
188
16
204
import typer class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): FILL_FUNC_BODYdef main( custom_arg: CustomClass = typer.Argument(parser=parse_custom_class), custom_o...
import typer class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): FILL_FUNC_BODYdef main( custom_arg: CustomClass = typer.Argument(parser=parse_custom_class), custom_o...
26,648
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/custom_types/tutorial001_an.py
17,21
1,27
main
21,25
21,25
import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): return CustomClass(value * 2) def main( custom_arg: Annotat...
import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): return CustomClass(value * 2) def main( custom_arg: Annotat...
print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}")
print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}")
6
187
38
225
import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): return CustomClass(value * 2) def main( custom_arg: Annotat...
import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __str__(self): return f"<CustomClass: value={self.value}>" def parse_custom_class(value: str): return CustomClass(value * 2) def main( custom_arg: Annotat...
26,649
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/custom_types/tutorial002.py
20,24
1,30
main
24,28
24,28
import click import typer class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): return Custom...
import click import typer class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): return Custom...
print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}")
print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}")
6
192
38
230
import click import typer class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): return Custom...
import click import typer class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): return Custom...
26,650
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/custom_types/tutorial002.py
16,17
13,20
convert
CustomClassParser
17,20
17,20
class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): FILL_FUNC_BODY
class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): FILL_FUNC_BODY
return CustomClass(value * 3)
return CustomClass(value * 3)
4
43
16
59
import click import typer class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): FILL_FUNC_BODYdef mai...
import click import typer class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): FILL_FUNC_BODYdef mai...
26,651
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/custom_types/tutorial002_an.py
21,27
1,33
main
27,31
27,31
import click import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, v...
import click import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, v...
print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}")
print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}")
6
217
38
255
import click import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, v...
import click import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, v...
26,652
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/custom_types/tutorial002_an.py
17,18
14,21
convert
CustomClassParser
18,21
18,21
class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): FILL_FUNC_BODY
class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, value, param, ctx): FILL_FUNC_BODY
return CustomClass(value * 3)
return CustomClass(value * 3)
4
43
16
59
import click import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, v...
import click import typer from typing_extensions import Annotated class CustomClass: def __init__(self, value: str): self.value = value def __repr__(self): return f"<CustomClass: value={self.value}>" class CustomClassParser(click.ParamType): name = "CustomClass" def convert(self, v...
26,653
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial001.py
4,5
1,11
main
5,9
5,9
import typer def main(config: typer.FileText = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(config: typer.FileText = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
for line in config: print(f"Config line: {line}")
for line in config: print(f"Config line: {line}")
7
56
26
82
import typer def main(config: typer.FileText = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(config: typer.FileText = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,654
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial001_an.py
5,6
1,12
main
6,10
6,10
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
for line in config: print(f"Config line: {line}")
for line in config: print(f"Config line: {line}")
7
68
26
94
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,655
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial002.py
4,5
1,11
main
5,9
5,9
import typer def main(config: typer.FileTextWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(config: typer.FileTextWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
config.write("Some config written by the app") print("Config written")
config.write("Some config written by the app") print("Config written")
8
57
26
83
import typer def main(config: typer.FileTextWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(config: typer.FileTextWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,656
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial002_an.py
5,6
1,12
main
6,10
6,10
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileTextWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileTextWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
config.write("Some config written by the app") print("Config written")
config.write("Some config written by the app") print("Config written")
8
69
26
95
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileTextWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileTextWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,657
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial003.py
4,5
1,14
main
5,12
5,12
import typer def main(file: typer.FileBinaryRead = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(file: typer.FileBinaryRead = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
processed_total = 0 for bytes_chunk in file: # Process the bytes in bytes_chunk processed_total += len(bytes_chunk) print(f"Processed bytes total: {processed_total}")
processed_total = 0 for bytes_chunk in file: # Process the bytes in bytes_chunk processed_total += len(bytes_chunk) print(f"Processed bytes total: {processed_total}")
20
57
68
125
import typer def main(file: typer.FileBinaryRead = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(file: typer.FileBinaryRead = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,658
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial003_an.py
5,6
1,15
main
6,13
6,13
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryRead, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryRead, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
processed_total = 0 for bytes_chunk in file: # Process the bytes in bytes_chunk processed_total += len(bytes_chunk) print(f"Processed bytes total: {processed_total}")
processed_total = 0 for bytes_chunk in file: # Process the bytes in bytes_chunk processed_total += len(bytes_chunk) print(f"Processed bytes total: {processed_total}")
20
69
68
137
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryRead, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryRead, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,659
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial004.py
4,5
1,18
main
5,16
5,16
import typer def main(file: typer.FileBinaryWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(file: typer.FileBinaryWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
first_line_str = "some settings\n" # You cannot write str directly to a binary file, you have to encode it to get bytes first_line_bytes = first_line_str.encode("utf-8") # Then you can write the bytes file.write(first_line_bytes) # This is already bytes, it starts with b" second_line = b"la ...
first_line_str = "some settings\n" # You cannot write str directly to a binary file, you have to encode it to get bytes first_line_bytes = first_line_str.encode("utf-8") # Then you can write the bytes file.write(first_line_bytes) # This is already bytes, it starts with b" second_line = b"la ...
53
57
158
215
import typer def main(file: typer.FileBinaryWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(file: typer.FileBinaryWrite = typer.Option(...)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,660
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial004_an.py
5,6
1,19
main
6,17
6,17
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
first_line_str = "some settings\n" # You cannot write str directly to a binary file, you have to encode it to get bytes first_line_bytes = first_line_str.encode("utf-8") # Then you can write the bytes file.write(first_line_bytes) # This is already bytes, it starts with b" second_line = b"la ...
first_line_str = "some settings\n" # You cannot write str directly to a binary file, you have to encode it to get bytes first_line_bytes = first_line_str.encode("utf-8") # Then you can write the bytes file.write(first_line_bytes) # This is already bytes, it starts with b" second_line = b"la ...
53
69
158
227
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(file: Annotated[typer.FileBinaryWrite, typer.Option()]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,661
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial005.py
4,5
1,11
main
5,9
5,9
import typer def main(config: typer.FileText = typer.Option(..., mode="a")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(config: typer.FileText = typer.Option(..., mode="a")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
config.write("This is a single line\n") print("Config line written")
config.write("This is a single line\n") print("Config line written")
8
61
28
89
import typer def main(config: typer.FileText = typer.Option(..., mode="a")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(config: typer.FileText = typer.Option(..., mode="a")): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,662
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/file/tutorial005_an.py
5,6
1,12
main
6,10
6,10
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option(mode="a")]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option(mode="a")]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
config.write("This is a single line\n") print("Config line written")
config.write("This is a single line\n") print("Config line written")
8
72
28
100
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option(mode="a")]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(config: Annotated[typer.FileText, typer.Option(mode="a")]): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,663
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/index/tutorial001.py
4,5
1,13
main
5,11
5,11
import typer def main(name: str, age: int = 20, height_meters: float = 1.89, female: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(name: str, age: int = 20, height_meters: float = 1.89, female: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print(f"NAME is {name}, of type: {type(name)}") print(f"--age is {age}, of type: {type(age)}") print(f"--height-meters is {height_meters}, of type: {type(height_meters)}") print(f"--female is {female}, of type: {type(female)}")
print(f"NAME is {name}, of type: {type(name)}") print(f"--age is {age}, of type: {type(age)}") print(f"--height-meters is {height_meters}, of type: {type(height_meters)}") print(f"--female is {female}, of type: {type(female)}")
24
69
100
169
import typer def main(name: str, age: int = 20, height_meters: float = 1.89, female: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(name: str, age: int = 20, height_meters: float = 1.89, female: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,664
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/number/tutorial001.py
4,9
1,16
main
9,14
9,14
import typer def main( id: int = typer.Argument(..., min=0, max=1000), age: int = typer.Option(20, min=18), score: float = typer.Option(0, max=100), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main( id: int = typer.Argument(..., min=0, max=1000), age: int = typer.Option(20, min=18), score: float = typer.Option(0, max=100), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print(f"ID is {id}") print(f"--age is {age}") print(f"--score is {score}")
print(f"ID is {id}") print(f"--age is {age}") print(f"--score is {score}")
9
104
43
147
import typer def main( id: int = typer.Argument(..., min=0, max=1000), age: int = typer.Option(20, min=18), score: float = typer.Option(0, max=100), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main( id: int = typer.Argument(..., min=0, max=1000), age: int = typer.Option(20, min=18), score: float = typer.Option(0, max=100), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,665
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/number/tutorial001_an.py
5,10
1,17
main
10,15
10,15
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], age: Annotated[int, typer.Option(min=18)] = 20, score: Annotated[float, typer.Option(max=100)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], age: Annotated[int, typer.Option(min=18)] = 20, score: Annotated[float, typer.Option(max=100)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print(f"ID is {id}") print(f"--age is {age}") print(f"--score is {score}")
print(f"ID is {id}") print(f"--age is {age}") print(f"--score is {score}")
9
126
43
169
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], age: Annotated[int, typer.Option(min=18)] = 20, score: Annotated[float, typer.Option(max=100)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], age: Annotated[int, typer.Option(min=18)] = 20, score: Annotated[float, typer.Option(max=100)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,666
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/number/tutorial002.py
4,9
1,16
main
9,14
9,14
import typer def main( id: int = typer.Argument(..., min=0, max=1000), rank: int = typer.Option(0, max=10, clamp=True), score: float = typer.Option(0, min=0, max=100, clamp=True), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main( id: int = typer.Argument(..., min=0, max=1000), rank: int = typer.Option(0, max=10, clamp=True), score: float = typer.Option(0, min=0, max=100, clamp=True), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print(f"ID is {id}") print(f"--rank is {rank}") print(f"--score is {score}")
print(f"ID is {id}") print(f"--rank is {rank}") print(f"--score is {score}")
9
117
43
160
import typer def main( id: int = typer.Argument(..., min=0, max=1000), rank: int = typer.Option(0, max=10, clamp=True), score: float = typer.Option(0, min=0, max=100, clamp=True), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main( id: int = typer.Argument(..., min=0, max=1000), rank: int = typer.Option(0, max=10, clamp=True), score: float = typer.Option(0, min=0, max=100, clamp=True), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,667
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/number/tutorial002_an.py
5,10
1,17
main
10,15
10,15
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], rank: Annotated[int, typer.Option(max=10, clamp=True)] = 0, score: Annotated[float, typer.Option(min=0, max=100, clamp=True)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(m...
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], rank: Annotated[int, typer.Option(max=10, clamp=True)] = 0, score: Annotated[float, typer.Option(min=0, max=100, clamp=True)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(m...
print(f"ID is {id}") print(f"--rank is {rank}") print(f"--score is {score}")
print(f"ID is {id}") print(f"--rank is {rank}") print(f"--score is {score}")
9
139
43
182
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], rank: Annotated[int, typer.Option(max=10, clamp=True)] = 0, score: Annotated[float, typer.Option(min=0, max=100, clamp=True)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(m...
import typer from typing_extensions import Annotated def main( id: Annotated[int, typer.Argument(min=0, max=1000)], rank: Annotated[int, typer.Option(max=10, clamp=True)] = 0, score: Annotated[float, typer.Option(min=0, max=100, clamp=True)] = 0, ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(m...
26,668
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/number/tutorial003.py
4,5
1,10
main
5,8
5,8
import typer def main(verbose: int = typer.Option(0, "--verbose", "-v", count=True)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(verbose: int = typer.Option(0, "--verbose", "-v", count=True)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print(f"Verbose level is {verbose}")
print(f"Verbose level is {verbose}")
4
65
20
85
import typer def main(verbose: int = typer.Option(0, "--verbose", "-v", count=True)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(verbose: int = typer.Option(0, "--verbose", "-v", count=True)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,669
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/number/tutorial003_an.py
5,6
1,11
main
6,9
6,9
import typer from typing_extensions import Annotated def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print(f"Verbose level is {verbose}")
print(f"Verbose level is {verbose}")
4
77
20
97
import typer from typing_extensions import Annotated def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from typing_extensions import Annotated def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,670
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/path/tutorial001.py
7,8
1,22
main
8,20
8,20
from pathlib import Path from typing import Optional import typer def main(config: Optional[Path] = typer.Option(None)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
from pathlib import Path from typing import Optional import typer def main(config: Optional[Path] = typer.Option(None)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if config is None: print("No config file") raise typer.Abort() if config.is_file(): text = config.read_text() print(f"Config file contents: {text}") elif config.is_dir(): print("Config is a directory, will use all its config files") elif not config.exists(): ...
if config is None: print("No config file") raise typer.Abort() if config.is_file(): text = config.read_text() print(f"Config file contents: {text}") elif config.is_dir(): print("Config is a directory, will use all its config files") elif not config.exists(): ...
37
67
115
182
from pathlib import Path from typing import Optional import typer def main(config: Optional[Path] = typer.Option(None)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
from pathlib import Path from typing import Optional import typer def main(config: Optional[Path] = typer.Option(None)): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,671
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/path/tutorial001_an.py
8,9
1,23
main
9,21
9,21
from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated def main(config: Annotated[Optional[Path], typer.Option()] = None): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated def main(config: Annotated[Optional[Path], typer.Option()] = None): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if config is None: print("No config file") raise typer.Abort() if config.is_file(): text = config.read_text() print(f"Config file contents: {text}") elif config.is_dir(): print("Config is a directory, will use all its config files") elif not config.exists(): ...
if config is None: print("No config file") raise typer.Abort() if config.is_file(): text = config.read_text() print(f"Config file contents: {text}") elif config.is_dir(): print("Config is a directory, will use all its config files") elif not config.exists(): ...
37
80
115
195
from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated def main(config: Annotated[Optional[Path], typer.Option()] = None): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
from pathlib import Path from typing import Optional import typer from typing_extensions import Annotated def main(config: Annotated[Optional[Path], typer.Option()] = None): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,672
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/path/tutorial002.py
6,17
1,23
main
17,21
17,21
from pathlib import Path import typer def main( config: Path = typer.Option( ..., exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
from pathlib import Path import typer def main( config: Path = typer.Option( ..., exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
text = config.read_text() print(f"Config file contents: {text}")
text = config.read_text() print(f"Config file contents: {text}")
7
113
30
143
from pathlib import Path import typer def main( config: Path = typer.Option( ..., exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
from pathlib import Path import typer def main( config: Path = typer.Option( ..., exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ), ): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,673
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/parameter_types/path/tutorial002_an.py
7,20
1,26
main
20,24
20,24
from pathlib import Path import typer from typing_extensions import Annotated def main( config: Annotated[ Path, typer.Option( exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ...
from pathlib import Path import typer from typing_extensions import Annotated def main( config: Annotated[ Path, typer.Option( exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ...
text = config.read_text() print(f"Config file contents: {text}")
text = config.read_text() print(f"Config file contents: {text}")
7
129
30
159
from pathlib import Path import typer from typing_extensions import Annotated def main( config: Annotated[ Path, typer.Option( exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ...
from pathlib import Path import typer from typing_extensions import Annotated def main( config: Annotated[ Path, typer.Option( exists=True, file_okay=True, dir_okay=False, writable=False, readable=True, resolve_path=True, ...
26,674
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/printing/tutorial001.py
13,14
1,20
main
14,18
14,18
import typer from rich import print data = { "name": "Rick", "age": 42, "items": [{"name": "Portal Gun"}, {"name": "Plumbus"}], "active": True, "affiliation": None, } def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich import print data = { "name": "Rick", "age": 42, "items": [{"name": "Portal Gun"}, {"name": "Plumbus"}], "active": True, "affiliation": None, } def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print("Here's the data") print(data)
print("Here's the data") print(data)
4
108
22
130
import typer from rich import print data = { "name": "Rick", "age": 42, "items": [{"name": "Portal Gun"}, {"name": "Plumbus"}], "active": True, "affiliation": None, } def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich import print data = { "name": "Rick", "age": 42, "items": [{"name": "Portal Gun"}, {"name": "Plumbus"}], "active": True, "affiliation": None, } def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,675
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/printing/tutorial002.py
5,6
1,11
main
6,9
6,9
import typer from rich import print def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich import print def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
print("[bold red]Alert![/bold red] [green]Portal gun[/green] shooting! :boom:")
print("[bold red]Alert![/bold red] [green]Portal gun[/green] shooting! :boom:")
7
45
36
81
import typer from rich import print def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich import print def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,676
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/printing/tutorial003.py
8,9
1,17
main
9,15
9,15
import typer from rich.console import Console from rich.table import Table console = Console() def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich.console import Console from rich.table import Table console = Console() def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
table = Table("Name", "Item") table.add_row("Rick", "Portal Gun") table.add_row("Morty", "Plumbus") console.print(table)
table = Table("Name", "Item") table.add_row("Rick", "Portal Gun") table.add_row("Morty", "Plumbus") console.print(table)
10
60
60
120
import typer from rich.console import Console from rich.table import Table console = Console() def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich.console import Console from rich.table import Table console = Console() def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,677
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/printing/tutorial004.py
7,8
1,13
main
8,11
8,11
import typer from rich.console import Console err_console = Console(stderr=True) def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich.console import Console err_console = Console(stderr=True) def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
err_console.print("Here is something written to standard error")
err_console.print("Here is something written to standard error")
7
60
21
81
import typer from rich.console import Console err_console = Console(stderr=True) def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich.console import Console err_console = Console(stderr=True) def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,678
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/printing/tutorial005.py
4,5
1,16
main
5,14
5,14
import typer def main(good: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(good: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
message_start = "everything is " if good: ending = typer.style("good", fg=typer.colors.GREEN, bold=True) else: ending = typer.style("bad", fg=typer.colors.WHITE, bg=typer.colors.RED) message = message_start + ending typer.echo(message)
message_start = "everything is " if good: ending = typer.style("good", fg=typer.colors.GREEN, bold=True) else: ending = typer.style("bad", fg=typer.colors.WHITE, bg=typer.colors.RED) message = message_start + ending typer.echo(message)
24
46
109
155
import typer def main(good: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(good: bool = True): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,679
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/printing/tutorial006.py
4,5
1,10
main
5,8
5,8
import typer def main(name: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(name: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
typer.secho(f"Welcome here {name}", fg=typer.colors.MAGENTA)
typer.secho(f"Welcome here {name}", fg=typer.colors.MAGENTA)
4
44
35
79
import typer def main(name: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(name: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,680
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/progressbar/tutorial001.py
7,8
1,18
main
8,16
8,16
import time import typer from rich.progress import track def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer from rich.progress import track def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
total = 0 for value in track(range(100), description="Processing..."): # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} things.")
total = 0 for value in track(range(100), description="Processing..."): # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} things.")
19
51
71
122
import time import typer from rich.progress import track def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer from rich.progress import track def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,681
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/progressbar/tutorial002.py
7,8
1,21
main
8,19
8,19
import time import typer from rich.progress import Progress, SpinnerColumn, TextColumn def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer from rich.progress import Progress, SpinnerColumn, TextColumn def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
with Progress( SpinnerColumn(), TextColumn("[progress.description]{task.description}"), transient=True, ) as progress: progress.add_task(description="Processing...", total=None) progress.add_task(description="Preparing...", total=None) time.sleep(5) print("Don...
with Progress( SpinnerColumn(), TextColumn("[progress.description]{task.description}"), transient=True, ) as progress: progress.add_task(description="Processing...", total=None) progress.add_task(description="Preparing...", total=None) time.sleep(5) print("Don...
14
58
104
162
import time import typer from rich.progress import Progress, SpinnerColumn, TextColumn def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer from rich.progress import Progress, SpinnerColumn, TextColumn def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,682
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/progressbar/tutorial003.py
6,7
1,18
main
7,16
7,16
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
total = 0 with typer.progressbar(range(100)) as progress: for value in progress: # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} things.")
total = 0 with typer.progressbar(range(100)) as progress: for value in progress: # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} things.")
22
44
77
121
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,683
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/progressbar/tutorial004.py
12,13
1,24
main
13,22
13,22
import time import typer def iterate_user_ids(): # Let's imagine this is a web API, not a range() for i in range(100): yield i def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def iterate_user_ids(): # Let's imagine this is a web API, not a range() for i in range(100): yield i def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
total = 0 with typer.progressbar(iterate_user_ids(), length=100) as progress: for value in progress: # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} user IDs.")
total = 0 with typer.progressbar(iterate_user_ids(), length=100) as progress: for value in progress: # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} user IDs.")
24
87
86
173
import time import typer def iterate_user_ids(): # Let's imagine this is a web API, not a range() for i in range(100): yield i def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def iterate_user_ids(): # Let's imagine this is a web API, not a range() for i in range(100): yield i def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,684
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/progressbar/tutorial005.py
6,7
1,18
main
7,16
7,16
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
total = 0 with typer.progressbar(range(100), label="Processing") as progress: for value in progress: # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} things.")
total = 0 with typer.progressbar(range(100), label="Processing") as progress: for value in progress: # Fake processing time time.sleep(0.01) total += 1 print(f"Processed {total} things.")
23
44
83
127
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,685
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/progressbar/tutorial006.py
6,7
1,18
main
7,16
7,16
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
total = 1000 with typer.progressbar(length=total) as progress: for batch in range(4): # Fake processing time time.sleep(1) progress.update(250) print(f"Processed {total} things in batches.")
total = 1000 with typer.progressbar(length=total) as progress: for batch in range(4): # Fake processing time time.sleep(1) progress.update(250) print(f"Processed {total} things in batches.")
22
44
85
129
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import time import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,686
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/prompt/tutorial001.py
4,5
1,11
main
5,9
5,9
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
person_name = typer.prompt("What's your name?") print(f"Hello {person_name}")
person_name = typer.prompt("What's your name?") print(f"Hello {person_name}")
7
40
38
78
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,687
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/prompt/tutorial002.py
4,5
1,14
main
5,12
5,12
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
delete = typer.confirm("Are you sure you want to delete it?") if not delete: print("Not deleting") raise typer.Abort() print("Deleting it!")
delete = typer.confirm("Are you sure you want to delete it?") if not delete: print("Not deleting") raise typer.Abort() print("Deleting it!")
19
40
61
101
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,688
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/prompt/tutorial003.py
4,5
1,11
main
5,9
5,9
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
delete = typer.confirm("Are you sure you want to delete it?", abort=True) print("Deleting it!")
delete = typer.confirm("Are you sure you want to delete it?", abort=True) print("Deleting it!")
13
40
41
81
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,689
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/prompt/tutorial004.py
5,6
1,12
main
6,10
6,10
import typer from rich.prompt import Prompt def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich.prompt import Prompt def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
name = Prompt.ask("Enter your name :sunglasses:") print(f"Hey there {name}!")
name = Prompt.ask("Enter your name :sunglasses:") print(f"Hey there {name}!")
9
49
37
86
import typer from rich.prompt import Prompt def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer from rich.prompt import Prompt def main(): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,690
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/callback_override/tutorial001.py
14,16
1,21
create
16,19
16,19
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users") @users_app.callback() def users_callback(): print("Running a users command") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users") @users_app.callback() def users_callback(): print("Running a users command") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
111
19
130
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users") @users_app.callback() def users_callback(): print("Running a users command") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users") @users_app.callback() def users_callback(): print("Running a users command") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,691
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/callback_override/tutorial002.py
6,7
1,21
users_callback
7,10
7,10
import typer app = typer.Typer() def users_callback(): FILL_FUNC_BODYusers_app = typer.Typer(callback=users_callback) app.add_typer(users_app, name="users") @users_app.command() def create(name: str): print(f"Creating user: {name}") if __name__ == "__main__": app()
import typer app = typer.Typer() def users_callback(): FILL_FUNC_BODYusers_app = typer.Typer(callback=users_callback) app.add_typer(users_app, name="users") @users_app.command() def create(name: str): print(f"Creating user: {name}") if __name__ == "__main__": app()
print("Running a users command")
print("Running a users command")
4
115
14
129
import typer app = typer.Typer() def users_callback(): FILL_FUNC_BODYusers_app = typer.Typer(callback=users_callback) app.add_typer(users_app, name="users") @users_app.command() def create(name: str): print(f"Creating user: {name}") if __name__ == "__main__": app()
import typer app = typer.Typer() def users_callback(): FILL_FUNC_BODYusers_app = typer.Typer(callback=users_callback) app.add_typer(users_app, name="users") @users_app.command() def create(name: str): print(f"Creating user: {name}") if __name__ == "__main__": app()
26,692
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/callback_override/tutorial003.py
19,21
1,26
create
21,24
21,24
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) app.add_typer(users_app, name="users") @users_app.callback() def user_callback(): print("Callback override, running users command") @users_app.command() def creat...
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) app.add_typer(users_app, name="users") @users_app.callback() def user_callback(): print("Callback override, running users command") @users_app.command() def creat...
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
137
19
156
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) app.add_typer(users_app, name="users") @users_app.callback() def user_callback(): print("Callback override, running users command") @users_app.command() def creat...
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) app.add_typer(users_app, name="users") @users_app.callback() def user_callback(): print("Callback override, running users command") @users_app.command() def creat...
26,693
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/callback_override/tutorial004.py
13,14
1,32
callback_for_add_typer
14,17
14,17
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) def callback_for_add_typer(): FILL_FUNC_BODYapp.add_typer(users_app, name="users", callback=callback_for_add_typer) @users_app.callback() def user_callback(): pri...
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) def callback_for_add_typer(): FILL_FUNC_BODYapp.add_typer(users_app, name="users", callback=callback_for_add_typer) @users_app.callback() def user_callback(): pri...
print("I have the high land! Running users command")
print("I have the high land! Running users command")
8
177
19
196
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) def callback_for_add_typer(): FILL_FUNC_BODYapp.add_typer(users_app, name="users", callback=callback_for_add_typer) @users_app.callback() def user_callback(): pri...
import typer app = typer.Typer() def default_callback(): print("Running a users command") users_app = typer.Typer(callback=default_callback) def callback_for_add_typer(): FILL_FUNC_BODYapp.add_typer(users_app, name="users", callback=callback_for_add_typer) @users_app.callback() def user_callback(): pri...
26,694
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial001.py
9,11
1,16
create
11,14
11,14
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users", help="Manage users in the app.") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users", help="Manage users in the app.") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
96
19
115
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users", help="Manage users in the app.") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app, name="users", help="Manage users in the app.") @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,695
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial002.py
16,18
1,23
create
18,21
18,21
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
110
19
129
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() users_app = typer.Typer() app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,696
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial003.py
16,18
1,23
create
18,21
18,21
import typer app = typer.Typer() def users(): """ Manage users in the app. """ users_app = typer.Typer(callback=users) app.add_typer(users_app) @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() def users(): """ Manage users in the app. """ users_app = typer.Typer(callback=users) app.add_typer(users_app) @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
107
19
126
import typer app = typer.Typer() def users(): """ Manage users in the app. """ users_app = typer.Typer(callback=users) app.add_typer(users_app) @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() def users(): """ Manage users in the app. """ users_app = typer.Typer(callback=users) app.add_typer(users_app) @users_app.command() def create(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,697
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial004.py
23,25
1,30
create
25,28
25,28
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name...
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
137
19
156
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) app.add_typer(users_app) @users_app.callback() def users(): """ Manage users in the app. """ @users_app.command() def create(name: str): FILL_FUNC_BODYif __name...
26,698
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial005.py
31,33
1,38
create
33,36
33,36
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_app.callback() def users(): """ M...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_app.callback() def users(): """ M...
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
171
19
190
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_app.callback() def users(): """ M...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback) def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_app.callback() def users(): """ M...
26,699
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial006.py
31,33
1,38
create
33,36
33,36
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
185
19
204
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
26,700
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial007.py
31,33
1,38
create
33,36
33,36
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
198
19
217
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer(users_app, callback=new_users) @users_...
26,701
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/name_help/tutorial008.py
36,38
1,43
create
38,41
38,41
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer( users_app, callback=new_users, ...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer( users_app, callback=new_users, ...
print(f"Creating user: {name}")
print(f"Creating user: {name}")
3
231
19
250
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer( users_app, callback=new_users, ...
import typer app = typer.Typer() def old_callback(): """ Old callback help. """ users_app = typer.Typer(callback=old_callback, name="exp-users", help="Explicit help.") def new_users(): """ I have the highland! Create some users. """ app.add_typer( users_app, callback=new_users, ...
26,702
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial001/items.py
16,18
1,23
sell
18,21
18,21
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Selling item: {item}")
print(f"Selling item: {item}")
3
116
19
135
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,703
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial001/users.py
6,8
1,18
create
8,11
8,11
import typer app = typer.Typer() @app.command() def create(user_name: str): FILL_FUNC_BODY@app.command() def delete(user_name: str): print(f"Deleting user: {user_name}") if __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(user_name: str): FILL_FUNC_BODY@app.command() def delete(user_name: str): print(f"Deleting user: {user_name}") if __name__ == "__main__": app()
print(f"Creating user: {user_name}")
print(f"Creating user: {user_name}")
3
92
21
113
import typer app = typer.Typer() @app.command() def create(user_name: str): FILL_FUNC_BODY@app.command() def delete(user_name: str): print(f"Deleting user: {user_name}") if __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(user_name: str): FILL_FUNC_BODY@app.command() def delete(user_name: str): print(f"Deleting user: {user_name}") if __name__ == "__main__": app()
26,704
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial002/main.py
25,27
1,37
users_create
27,30
27,30
import typer app = typer.Typer() items_app = typer.Typer() app.add_typer(items_app, name="items") users_app = typer.Typer() app.add_typer(users_app, name="users") @items_app.command("create") def items_create(item: str): print(f"Creating item: {item}") @items_app.command("delete") def items_delete(item: str): ...
import typer app = typer.Typer() items_app = typer.Typer() app.add_typer(items_app, name="items") users_app = typer.Typer() app.add_typer(users_app, name="users") @items_app.command("create") def items_create(item: str): print(f"Creating item: {item}") @items_app.command("delete") def items_delete(item: str): ...
print(f"Creating user: {user_name}")
print(f"Creating user: {user_name}")
3
271
21
292
import typer app = typer.Typer() items_app = typer.Typer() app.add_typer(items_app, name="items") users_app = typer.Typer() app.add_typer(users_app, name="users") @items_app.command("create") def items_create(item: str): print(f"Creating item: {item}") @items_app.command("delete") def items_delete(item: str): ...
import typer app = typer.Typer() items_app = typer.Typer() app.add_typer(items_app, name="items") users_app = typer.Typer() app.add_typer(users_app, name="users") @items_app.command("create") def items_create(item: str): print(f"Creating item: {item}") @items_app.command("delete") def items_delete(item: str): ...
26,705
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial003/items.py
16,18
1,23
sell
18,21
18,21
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Selling item: {item}")
print(f"Selling item: {item}")
3
116
19
135
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(item: str): print(f"Creating item: {item}") @app.command() def delete(item: str): print(f"Deleting item: {item}") @app.command() def sell(item: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,706
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial003/reigns.py
11,13
1,18
destroy
13,16
13,16
import typer app = typer.Typer() @app.command() def conquer(name: str): print(f"Conquering reign: {name}") @app.command() def destroy(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def conquer(name: str): print(f"Conquering reign: {name}") @app.command() def destroy(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Destroying reign: {name}")
print(f"Destroying reign: {name}")
3
86
20
106
import typer app = typer.Typer() @app.command() def conquer(name: str): print(f"Conquering reign: {name}") @app.command() def destroy(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def conquer(name: str): print(f"Conquering reign: {name}") @app.command() def destroy(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,707
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial003/towns.py
11,13
1,18
burn
13,16
13,16
import typer app = typer.Typer() @app.command() def found(name: str): print(f"Founding town: {name}") @app.command() def burn(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def found(name: str): print(f"Founding town: {name}") @app.command() def burn(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Burning town: {name}")
print(f"Burning town: {name}")
3
85
20
105
import typer app = typer.Typer() @app.command() def found(name: str): print(f"Founding town: {name}") @app.command() def burn(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def found(name: str): print(f"Founding town: {name}") @app.command() def burn(name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,708
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/subcommands/tutorial003/users.py
11,13
1,18
delete
13,16
13,16
import typer app = typer.Typer() @app.command() def create(user_name: str): print(f"Creating user: {user_name}") @app.command() def delete(user_name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(user_name: str): print(f"Creating user: {user_name}") @app.command() def delete(user_name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
print(f"Deleting user: {user_name}")
print(f"Deleting user: {user_name}")
3
91
22
113
import typer app = typer.Typer() @app.command() def create(user_name: str): print(f"Creating user: {user_name}") @app.command() def delete(user_name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
import typer app = typer.Typer() @app.command() def create(user_name: str): print(f"Creating user: {user_name}") @app.command() def delete(user_name: str): FILL_FUNC_BODYif __name__ == "__main__": app()
26,709
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/terminating/tutorial001.py
14,15
1,26
send_new_user_notification
15,19
15,19
import typer existing_usernames = ["rick", "morty"] def maybe_create_user(username: str): if username in existing_usernames: print("The user already exists") raise typer.Exit() else: print(f"User created: {username}") def send_new_user_notification(username: str): FILL_FUNC_BODYdef ...
import typer existing_usernames = ["rick", "morty"] def maybe_create_user(username: str): if username in existing_usernames: print("The user already exists") raise typer.Exit() else: print(f"User created: {username}") def send_new_user_notification(username: str): FILL_FUNC_BODYdef ...
# Somehow send a notification here for the new user, maybe an email print(f"Notification sent for new user: {username}")
# Somehow send a notification here for the new user, maybe an email print(f"Notification sent for new user: {username}")
19
164
39
203
import typer existing_usernames = ["rick", "morty"] def maybe_create_user(username: str): if username in existing_usernames: print("The user already exists") raise typer.Exit() else: print(f"User created: {username}") def send_new_user_notification(username: str): FILL_FUNC_BODYdef ...
import typer existing_usernames = ["rick", "morty"] def maybe_create_user(username: str): if username in existing_usernames: print("The user already exists") raise typer.Exit() else: print(f"User created: {username}") def send_new_user_notification(username: str): FILL_FUNC_BODYdef ...
26,710
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/terminating/tutorial002.py
4,5
1,13
main
5,11
5,11
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if username == "root": print("The root user is reserved") raise typer.Exit(code=1) print(f"New user created: {username}")
if username == "root": print("The root user is reserved") raise typer.Exit(code=1) print(f"New user created: {username}")
15
44
52
96
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,711
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/terminating/tutorial003.py
4,5
1,13
main
5,11
5,11
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
if username == "root": print("The root user is reserved") raise typer.Abort() print(f"New user created: {username}")
if username == "root": print("The root user is reserved") raise typer.Abort() print(f"New user created: {username}")
15
44
49
93
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
import typer def main(username: str): FILL_FUNC_BODYif __name__ == "__main__": typer.run(main)
26,712
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/using_click/tutorial002.py
9,11
1,25
initdb
11,14
11,14
import click @click.group() def cli(): pass @click.command() def initdb(): FILL_FUNC_BODY@click.command() def dropdb(): click.echo("Dropped the database") cli.add_command(initdb) cli.add_command(dropdb) if __name__ == "__main__": cli()
import click @click.group() def cli(): pass @click.command() def initdb(): FILL_FUNC_BODY@click.command() def dropdb(): click.echo("Dropped the database") cli.add_command(initdb) cli.add_command(dropdb) if __name__ == "__main__": cli()
click.echo("Initialized the database")
click.echo("Initialized the database")
3
104
16
120
import click @click.group() def cli(): pass @click.command() def initdb(): FILL_FUNC_BODY@click.command() def dropdb(): click.echo("Dropped the database") cli.add_command(initdb) cli.add_command(dropdb) if __name__ == "__main__": cli()
import click @click.group() def cli(): pass @click.command() def initdb(): FILL_FUNC_BODY@click.command() def dropdb(): click.echo("Dropped the database") cli.add_command(initdb) cli.add_command(dropdb) if __name__ == "__main__": cli()
26,713
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/using_click/tutorial003.py
7,9
1,35
top
12,15
9,15
import click import typer app = typer.Typer() @app.command() def top(): FILL_FUNC_BODY@app.callback() def callback(): """ Typer app, including Click subapp """ @click.command() @click.option("--name", prompt="Your name", help="The person to greet.") def hello(name): """Simple program that greets NA...
import click import typer app = typer.Typer() @app.command() def top(): """ Top level command, form Typer """ FILL_FUNC_BODY@app.callback() def callback(): """ Typer app, including Click subapp """ @click.command() @click.option("--name", prompt="Your name", help="The person to greet.") def...
print("The Typer app is at the top level")
""" Top level command, form Typer """ print("The Typer app is at the top level")
8
207
19
226
import click import typer app = typer.Typer() @app.command() def top(): FILL_FUNC_BODY@app.callback() def callback(): """ Typer app, including Click subapp """ @click.command() @click.option("--name", prompt="Your name", help="The person to greet.") def hello(name): """Simple program that greets NA...
import click import typer app = typer.Typer() @app.command() def top(): """ Top level command, form Typer """ FILL_FUNC_BODY@app.callback() def callback(): """ Typer app, including Click subapp """ @click.command() @click.option("--name", prompt="Your name", help="The person to greet.") def...
26,714
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/docs_src/using_click/tutorial004.py
10,12
1,37
initdb
12,15
12,15
import click import typer @click.group() def cli(): pass @cli.command() def initdb(): FILL_FUNC_BODY@cli.command() def dropdb(): click.echo("Dropped the database") app = typer.Typer() @app.command() def sub(): """ A single-command Typer sub app """ print("Typer is now below Click, the Cl...
import click import typer @click.group() def cli(): pass @cli.command() def initdb(): FILL_FUNC_BODY@cli.command() def dropdb(): click.echo("Dropped the database") app = typer.Typer() @app.command() def sub(): """ A single-command Typer sub app """ print("Typer is now below Click, the Cl...
click.echo("Initialized the database")
click.echo("Initialized the database")
3
182
16
198
import click import typer @click.group() def cli(): pass @cli.command() def initdb(): FILL_FUNC_BODY@cli.command() def dropdb(): click.echo("Dropped the database") app = typer.Typer() @app.command() def sub(): """ A single-command Typer sub app """ print("Typer is now below Click, the Cl...
import click import typer @click.group() def cli(): pass @cli.command() def initdb(): FILL_FUNC_BODY@cli.command() def dropdb(): click.echo("Dropped the database") app = typer.Typer() @app.command() def sub(): """ A single-command Typer sub app """ print("Typer is now below Click, the Cl...
26,716
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/_completion_classes.py
53,54
24,60
complete
BashComplete
54,60
54,60
class BashComplete(click.shell_completion.BashComplete): name = Shells.bash.value source_template = COMPLETION_SCRIPT_BASH def source_vars(self) -> Dict[str, Any]: return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self....
class BashComplete(click.shell_completion.BashComplete): name = Shells.bash.value source_template = COMPLETION_SCRIPT_BASH def source_vars(self) -> Dict[str, Any]: return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self....
args, incomplete = self.get_completion_args() completions = self.get_completions(args, incomplete) out = [self.format_completion(item) for item in completions] return "\n".join(out)
args, incomplete = self.get_completion_args() completions = self.get_completions(args, incomplete) out = [self.format_completion(item) for item in completions] return "\n".join(out)
17
330
70
400
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
26,717
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/_completion_classes.py
114,115
110,163
source_vars
FishComplete
115,121
115,121
class FishComplete(click.shell_completion.FishComplete): name = Shells.fish.value source_template = COMPLETION_SCRIPT_FISH def source_vars(self) -> Dict[str, Any]: FILL_FUNC_BODY def get_completion_args(self) -> Tuple[List[str], str]: completion_args = os.getenv("_TYPER_COMPLETE_ARGS", "") ...
class FishComplete(click.shell_completion.FishComplete): name = Shells.fish.value source_template = COMPLETION_SCRIPT_FISH def source_vars(self) -> Dict[str, Any]: FILL_FUNC_BODY def get_completion_args(self) -> Tuple[List[str], str]: completion_args = os.getenv("_TYPER_COMPLETE_ARGS", "") ...
return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self.prog_name, }
return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self.prog_name, }
9
554
58
612
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
26,718
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/_completion_classes.py
167,168
163,185
source_vars
PowerShellComplete
168,174
168,174
class PowerShellComplete(click.shell_completion.ShellComplete): name = Shells.powershell.value source_template = COMPLETION_SCRIPT_POWER_SHELL def source_vars(self) -> Dict[str, Any]: FILL_FUNC_BODY def get_completion_args(self) -> Tuple[List[str], str]: completion_args = os.getenv("_TYPER_COMPL...
class PowerShellComplete(click.shell_completion.ShellComplete): name = Shells.powershell.value source_template = COMPLETION_SCRIPT_POWER_SHELL def source_vars(self) -> Dict[str, Any]: FILL_FUNC_BODY def get_completion_args(self) -> Tuple[List[str], str]: completion_args = os.getenv("_TYPER_COMPL...
return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self.prog_name, }
return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self.prog_name, }
9
233
58
291
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
26,719
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/_completion_classes.py
82,83
60,110
format_completion
ZshComplete
83,99
83,99
class ZshComplete(click.shell_completion.ZshComplete): name = Shells.zsh.value source_template = COMPLETION_SCRIPT_ZSH def source_vars(self) -> Dict[str, Any]: return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self.prog...
class ZshComplete(click.shell_completion.ZshComplete): name = Shells.zsh.value source_template = COMPLETION_SCRIPT_ZSH def source_vars(self) -> Dict[str, Any]: return { "complete_func": self.func_name, "autocomplete_var": self.complete_var, "prog_name": self.prog...
def escape(s: str) -> str: return ( s.replace('"', '""') .replace("'", "''") .replace("$", "\\$") .replace("`", "\\`") ) # TODO: Explore replicating the new behavior from Click, pay attention to # the differ...
def escape(s: str) -> str: return ( s.replace('"', '""') .replace("'", "''") .replace("$", "\\$") .replace("`", "\\`") ) # TODO: Explore replicating the new behavior from Click, pay attention to # the differ...
49
385
183
568
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
import os import re import sys from typing import Any, Dict, List, Tuple import click import click.parser import click.shell_completion from ._completion_shared import ( COMPLETION_SCRIPT_BASH, COMPLETION_SCRIPT_FISH, COMPLETION_SCRIPT_POWER_SHELL, COMPLETION_SCRIPT_ZSH, Shells, ) try: import...
26,722
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/cli.py
55,56
54,72
list_commands
TyperCLIGroup
56,59
56,59
class TyperCLIGroup(typer.core.TyperGroup): def list_commands(self, ctx: click.Context) -> List[str]: FILL_FUNC_BODY def get_command(self, ctx: click.Context, name: str) -> Optional[Command]: self.maybe_add_run(ctx) return super().get_command(ctx, name) def invoke(self, ctx: click.Context) -...
class TyperCLIGroup(typer.core.TyperGroup): def list_commands(self, ctx: click.Context) -> List[str]: FILL_FUNC_BODY def get_command(self, ctx: click.Context, name: str) -> Optional[Command]: self.maybe_add_run(ctx) return super().get_command(ctx, name) def invoke(self, ctx: click.Context) -...
self.maybe_add_run(ctx) return super().list_commands(ctx)
self.maybe_add_run(ctx) return super().list_commands(ctx)
3
186
28
214
import importlib.util import re import sys from pathlib import Path from typing import Any, List, Optional import click import typer import typer.core from click import Command, Group, Option from . import __version__ default_app_names = ("app", "cli", "main") default_func_names = ("main", "cli", "app") app = typer...
import importlib.util import re import sys from pathlib import Path from typing import Any, List, Optional import click import typer import typer.core from click import Command, Group, Option from . import __version__ default_app_names = ("app", "cli", "main") default_func_names = ("main", "cli", "app") app = typer...
26,723
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/completion.py
88,102
1,150
_install_completion_no_auto_placeholder_function
102,110
102,110
import os import sys from typing import Any, MutableMapping, Tuple import click from ._completion_classes import completion_init from ._completion_shared import Shells, get_completion_script, install from .models import ParamMeta from .params import Option from .utils import get_params_from_function try: import ...
import os import sys from typing import Any, MutableMapping, Tuple import click from ._completion_classes import completion_init from ._completion_shared import Shells, get_completion_script, install from .models import ParamMeta from .params import Option from .utils import get_params_from_function try: import ...
pass # pragma: no cover # Re-implement Click's shell_complete to add error message with: # Invalid completion instruction # To use 7.x instruction style for compatibility # And to add extra error messages, for compatibility with Typer in previous versions # This is only called in new Command method, only used by...
pass # pragma: no cover # Re-implement Click's shell_complete to add error message with: # Invalid completion instruction # To use 7.x instruction style for compatibility # And to add extra error messages, for compatibility with Typer in previous versions # This is only called in new Command method, only used by...
54
1,324
92
1,416
import os import sys from typing import Any, MutableMapping, Tuple import click from ._completion_classes import completion_init from ._completion_shared import Shells, get_completion_script, install from .models import ParamMeta from .params import Option from .utils import get_params_from_function try: import ...
import os import sys from typing import Any, MutableMapping, Tuple import click from ._completion_classes import completion_init from ._completion_shared import Shells, get_completion_script, install from .models import ParamMeta from .params import Option from .utils import get_params_from_function try: import ...
26,725
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/core.py
316,319
249,383
_extract_default_help_str
TyperArgument
319,321
319,321
class TyperArgument(click.core.Argument): def __init__( self, *, # Parameter param_decls: List[str], type: Optional[Any] = None, required: Optional[bool] = None, default: Optional[Any] = None, callback: Optional[Callable[..., Any]] = None, narg...
class TyperArgument(click.core.Argument): def __init__( self, *, # Parameter param_decls: List[str], type: Optional[Any] = None, required: Optional[bool] = None, default: Optional[Any] = None, callback: Optional[Callable[..., Any]] = None, narg...
return _extract_default_help_str(self, ctx=ctx)
return _extract_default_help_str(self, ctx=ctx)
3
1,367
22
1,389
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
26,726
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/core.py
652,661
600,681
main
TyperCommand
661,671
661,671
class TyperCommand(click.core.Command): def __init__( self, name: Optional[str], *, context_settings: Optional[Dict[str, Any]] = None, callback: Optional[Callable[..., Any]] = None, params: Optional[List[click.Parameter]] = None, help: Optional[str] = None, ...
class TyperCommand(click.core.Command): def __init__( self, name: Optional[str], *, context_settings: Optional[Dict[str, Any]] = None, callback: Optional[Callable[..., Any]] = None, params: Optional[List[click.Parameter]] = None, help: Optional[str] = None, ...
return _main( self, args=args, prog_name=prog_name, complete_var=complete_var, standalone_mode=standalone_mode, windows_expand_args=windows_expand_args, **extra, )
return _main( self, args=args, prog_name=prog_name, complete_var=complete_var, standalone_mode=standalone_mode, windows_expand_args=windows_expand_args, **extra, )
10
734
83
817
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
26,727
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/core.py
733,734
681,741
format_help
TyperGroup
734,741
734,741
class TyperGroup(click.core.Group): def __init__( self, *, name: Optional[str] = None, commands: Optional[ Union[Dict[str, click.Command], Sequence[click.Command]] ] = None, # Rich settings rich_markup_mode: MarkupMode = None, rich_help_pan...
class TyperGroup(click.core.Group): def __init__( self, *, name: Optional[str] = None, commands: Optional[ Union[Dict[str, click.Command], Sequence[click.Command]] ] = None, # Rich settings rich_markup_mode: MarkupMode = None, rich_help_pan...
if not rich: return super().format_help(ctx, formatter) return rich_utils.rich_format_help( obj=self, ctx=ctx, markup_mode=self.rich_markup_mode, )
if not rich: return super().format_help(ctx, formatter) return rich_utils.rich_format_help( obj=self, ctx=ctx, markup_mode=self.rich_markup_mode, )
12
548
71
619
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
26,728
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/core.py
472,473
383,558
get_help_record
TyperOption
473,558
473,558
class TyperOption(click.core.Option): def __init__( self, *, # Parameter param_decls: List[str], type: Optional[Union[click.types.ParamType, Any]] = None, required: Optional[bool] = None, default: Optional[Any] = None, callback: Optional[Callable[..., ...
class TyperOption(click.core.Option): def __init__( self, *, # Parameter param_decls: List[str], type: Optional[Union[click.types.ParamType, Any]] = None, required: Optional[bool] = None, default: Optional[Any] = None, callback: Optional[Callable[..., ...
# Duplicate all of Click's logic only to modify a single line, to allow boolean # flags with only names for False values as it's currently supported by Typer # Ref: https://typer.tiangolo.com/tutorial/parameter-types/bool/#only-names-for-false if self.hidden: return None ...
# Duplicate all of Click's logic only to modify a single line, to allow boolean # flags with only names for False values as it's currently supported by Typer # Ref: https://typer.tiangolo.com/tutorial/parameter-types/bool/#only-names-for-false if self.hidden: return None ...
231
949
897
1,846
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
import errno import inspect import os import sys from enum import Enum from gettext import gettext as _ from typing import ( Any, Callable, Dict, List, MutableMapping, Optional, Sequence, TextIO, Tuple, Union, cast, ) import click import click.core import click.formatting im...
26,733
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer
/home/hieuvd/dung_repo/raw/stars_01/tiangolo_typer/typer/typer/testing.py
10,20
9,30
invoke
CliRunner
20,30
20,30
class CliRunner(ClickCliRunner): def invoke( # type: ignore self, app: Typer, args: Optional[Union[str, Sequence[str]]] = None, input: Optional[Union[bytes, str, IO[Any]]] = None, env: Optional[Mapping[str, str]] = None, catch_exceptions: bool = True, color: ...
class CliRunner(ClickCliRunner): def invoke( # type: ignore self, app: Typer, args: Optional[Union[str, Sequence[str]]] = None, input: Optional[Union[bytes, str, IO[Any]]] = None, env: Optional[Mapping[str, str]] = None, catch_exceptions: bool = True, color: ...
use_cli = _get_command(app) return super().invoke( use_cli, args=args, input=input, env=env, catch_exceptions=catch_exceptions, color=color, **extra, )
use_cli = _get_command(app) return super().invoke( use_cli, args=args, input=input, env=env, catch_exceptions=catch_exceptions, color=color, **extra, )
13
131
80
211
from typing import IO, Any, Mapping, Optional, Sequence, Union from click.testing import CliRunner as ClickCliRunner # noqa from click.testing import Result from typer.main import Typer from typer.main import get_command as _get_command class CliRunner(ClickCliRunner): def invoke( # type: ignore self, ...
from typing import IO, Any, Mapping, Optional, Sequence, Union from click.testing import CliRunner as ClickCliRunner # noqa from click.testing import Result from typer.main import Typer from typer.main import get_command as _get_command class CliRunner(ClickCliRunner): def invoke( # type: ignore self, ...
26,734
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/chat/chatdemo.py
107,108
1,127
main
108,125
108,125
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
parse_command_line() app = tornado.web.Application( [ (r"/", MainHandler), (r"/a/message/new", MessageNewHandler), (r"/a/message/updates", MessageUpdatesHandler), ], cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__", template_path=o...
parse_command_line() app = tornado.web.Application( [ (r"/", MainHandler), (r"/a/message/new", MessageNewHandler), (r"/a/message/updates", MessageUpdatesHandler), ], cookie_secret="__TODO:_GENERATE_YOUR_OWN_RANDOM_VALUE_HERE__", template_path=o...
23
989
207
1,196
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
26,735
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/chat/chatdemo.py
60,61
59,64
get
MainHandler
61,64
61,64
class MainHandler(tornado.web.RequestHandler): def get(self): FILL_FUNC_BODY
class MainHandler(tornado.web.RequestHandler): def get(self): FILL_FUNC_BODY
self.render("index.html", messages=global_message_buffer.cache)
self.render("index.html", messages=global_message_buffer.cache)
2
31
25
56
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
26,736
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/chat/chatdemo.py
35,36
28,56
get_messages_since
MessageBuffer
40,48
36,48
class MessageBuffer(object): def __init__(self): # cond is notified whenever the message cache is updated self.cond = tornado.locks.Condition() self.cache = [] self.cache_size = 200 def get_messages_since(self, cursor): FILL_FUNC_BODY def add_message(self, message): s...
class MessageBuffer(object): def __init__(self): # cond is notified whenever the message cache is updated self.cond = tornado.locks.Condition() self.cache = [] self.cache_size = 200 def get_messages_since(self, cursor): """Returns a list of messages newer than the given ...
results = [] for msg in reversed(self.cache): if msg["id"] == cursor: break results.append(msg) results.reverse() return results
"""Returns a list of messages newer than the given cursor. ``cursor`` should be the ``id`` of the last message received. """ results = [] for msg in reversed(self.cache): if msg["id"] == cursor: break results.append(msg) results.re...
16
202
58
260
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
26,737
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/chat/chatdemo.py
67,68
64,81
post
MessageNewHandler
68,81
68,81
class MessageNewHandler(tornado.web.RequestHandler): """Post a new message to the chat room.""" def post(self): FILL_FUNC_BODY
class MessageNewHandler(tornado.web.RequestHandler): """Post a new message to the chat room.""" def post(self): FILL_FUNC_BODY
message = {"id": str(uuid.uuid4()), "body": self.get_argument("body")} # render_string() returns a byte string, which is not supported # in json, so we must convert it to a character string. message["html"] = tornado.escape.to_unicode( self.render_string("message.html", messa...
message = {"id": str(uuid.uuid4()), "body": self.get_argument("body")} # render_string() returns a byte string, which is not supported # in json, so we must convert it to a character string. message["html"] = tornado.escape.to_unicode( self.render_string("message.html", messa...
41
45
163
208
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
26,738
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/chat/chatdemo.py
87,88
81,107
post
MessageUpdatesHandler
88,103
88,103
class MessageUpdatesHandler(tornado.web.RequestHandler): """Long-polling request for new messages. Waits until new messages are available before returning anything. """ async def post(self): FILL_FUNC_BODY def on_connection_close(self): self.wait_future.cancel()
class MessageUpdatesHandler(tornado.web.RequestHandler): """Long-polling request for new messages. Waits until new messages are available before returning anything. """ async def post(self): FILL_FUNC_BODY def on_connection_close(self): self.wait_future.cancel()
cursor = self.get_argument("cursor", None) messages = global_message_buffer.get_messages_since(cursor) while not messages: # Save the Future returned here so we can cancel it in # on_connection_close. self.wait_future = global_message_buffer.cond.wait() ...
cursor = self.get_argument("cursor", None) messages = global_message_buffer.get_messages_since(cursor) while not messages: # Save the Future returned here so we can cancel it in # on_connection_close. self.wait_future = global_message_buffer.cond.wait() ...
40
87
167
254
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
#!/usr/bin/env python3 # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
26,739
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/file_upload/file_receiver.py
51,52
1,60
main
52,58
52,58
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
options.parse_command_line() app = make_app() app.listen(8888) await asyncio.Event().wait()
options.parse_command_line() app = make_app() app.listen(8888) await asyncio.Event().wait()
7
448
47
495
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
26,740
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/file_upload/file_receiver.py
20,21
19,32
post
POSTHandler
21,32
21,32
class POSTHandler(tornado.web.RequestHandler): def post(self): FILL_FUNC_BODY
class POSTHandler(tornado.web.RequestHandler): def post(self): FILL_FUNC_BODY
for field_name, files in self.request.files.items(): for info in files: filename, content_type = info["filename"], info["content_type"] body = info["body"] logging.info( 'POST "%s" "%s" %d bytes', filename, content_type, len(body) ...
for field_name, files in self.request.files.items(): for info in files: filename, content_type = info["filename"], info["content_type"] body = info["body"] logging.info( 'POST "%s" "%s" %d bytes', filename, content_type, len(body) ...
28
31
105
136
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
26,741
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/file_upload/file_receiver.py
40,41
32,47
put
PUTHandler
41,47
41,47
@tornado.web.stream_request_body class PUTHandler(tornado.web.RequestHandler): def initialize(self): self.bytes_read = 0 def data_received(self, chunk): self.bytes_read += len(chunk) def put(self, filename): FILL_FUNC_BODY
@tornado.web.stream_request_body class PUTHandler(tornado.web.RequestHandler): def initialize(self): self.bytes_read = 0 def data_received(self, chunk): self.bytes_read += len(chunk) def put(self, filename): FILL_FUNC_BODY
filename = unquote(filename) mtype = self.request.headers.get("Content-Type") logging.info('PUT "%s" "%s" %d bytes', filename, mtype, self.bytes_read) self.write("OK")
filename = unquote(filename) mtype = self.request.headers.get("Content-Type") logging.info('PUT "%s" "%s" %d bytes', filename, mtype, self.bytes_read) self.write("OK")
15
89
70
159
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
#!/usr/bin/env python """Usage: python file_receiver.py Demonstrates a server that receives a multipart-form-encoded set of files in an HTTP POST, or streams in the raw data of a single file in an HTTP PUT. See file_uploader.py in this directory for code that uploads files in this format. """ import asyncio import ...
26,742
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/file_upload/file_uploader.py
26,28
1,115
multipart_producer
28,58
28,58
#!/usr/bin/env python """Usage: python file_uploader.py [--put] file1.txt file2.png ... Demonstrates uploading files to a server, without concurrency. It can either POST a multipart-form-encoded request containing one or more files, or PUT a single file without encoding. See also file_receiver.py in this directory, ...
#!/usr/bin/env python """Usage: python file_uploader.py [--put] file1.txt file2.png ... Demonstrates uploading files to a server, without concurrency. It can either POST a multipart-form-encoded request containing one or more files, or PUT a single file without encoding. See also file_receiver.py in this directory, ...
boundary_bytes = boundary.encode() for filename in filenames: filename_bytes = filename.encode() mtype = mimetypes.guess_type(filename)[0] or "application/octet-stream" buf = ( (b"--%s\r\n" % boundary_bytes) + ( b'Content-Disposition: form-data; n...
boundary_bytes = boundary.encode() for filename in filenames: filename_bytes = filename.encode() mtype = mimetypes.guess_type(filename)[0] or "application/octet-stream" buf = ( (b"--%s\r\n" % boundary_bytes) + ( b'Content-Disposition: form-data; n...
99
750
339
1,089
#!/usr/bin/env python """Usage: python file_uploader.py [--put] file1.txt file2.png ... Demonstrates uploading files to a server, without concurrency. It can either POST a multipart-form-encoded request containing one or more files, or PUT a single file without encoding. See also file_receiver.py in this directory, ...
#!/usr/bin/env python """Usage: python file_uploader.py [--put] file1.txt file2.png ... Demonstrates uploading files to a server, without concurrency. It can either POST a multipart-form-encoded request containing one or more files, or PUT a single file without encoding. See also file_receiver.py in this directory, ...
26,743
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/google_auth/main.py
91,92
1,114
main
92,112
92,112
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
tornado.options.parse_command_line() app = tornado.web.Application( [ url(r"/", IndexHandler), url(r"/auth/google", LoginHandler, name="google_oauth"), url(r"/logout", LogoutHandler), ], redirect_base_uri=f"http://localhost:{options.port}", goo...
tornado.options.parse_command_line() app = tornado.web.Application( [ url(r"/", IndexHandler), url(r"/auth/google", LoginHandler, name="google_oauth"), url(r"/logout", LogoutHandler), ], redirect_base_uri=f"http://localhost:{options.port}", goo...
28
1,002
231
1,233
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
26,744
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/google_auth/main.py
32,33
31,39
get_current_user
BaseHandler
33,39
33,39
class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): FILL_FUNC_BODY
class BaseHandler(tornado.web.RequestHandler): def get_current_user(self): FILL_FUNC_BODY
user_cookie = self.get_signed_cookie("googledemo_user") if user_cookie: return json.loads(user_cookie) return None
user_cookie = self.get_signed_cookie("googledemo_user") if user_cookie: return json.loads(user_cookie) return None
9
35
57
92
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
26,745
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/google_auth/main.py
40,42
39,57
get
IndexHandler
42,57
42,57
class IndexHandler(BaseHandler, tornado.auth.GoogleOAuth2Mixin): @tornado.web.authenticated async def get(self): FILL_FUNC_BODY
class IndexHandler(BaseHandler, tornado.auth.GoogleOAuth2Mixin): @tornado.web.authenticated async def get(self): FILL_FUNC_BODY
try: # This is redundant: we got the userinfo in the login handler. # But this demonstrates the usage of oauth2_request outside of # the login flow, and getting anything more than userinfo # leads to more approval prompts and complexity. user_info = aw...
try: # This is redundant: we got the userinfo in the login handler. # But this demonstrates the usage of oauth2_request outside of # the login flow, and getting anything more than userinfo # leads to more approval prompts and complexity. user_info = aw...
56
50
182
232
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
26,746
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/google_auth/main.py
58,59
57,85
get
LoginHandler
59,85
59,85
class LoginHandler(BaseHandler, tornado.auth.GoogleOAuth2Mixin): async def get(self): FILL_FUNC_BODY
class LoginHandler(BaseHandler, tornado.auth.GoogleOAuth2Mixin): async def get(self): FILL_FUNC_BODY
redirect_uri = urllib.parse.urljoin( self.application.settings["redirect_base_uri"], self.reverse_url("google_oauth"), ) if self.get_argument("code", False): access = await self.get_authenticated_user( redirect_uri=redirect_uri, code=self.get_a...
redirect_uri = urllib.parse.urljoin( self.application.settings["redirect_base_uri"], self.reverse_url("google_oauth"), ) if self.get_argument("code", False): access = await self.get_authenticated_user( redirect_uri=redirect_uri, code=self.get_a...
47
38
332
370
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
26,747
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/google_auth/main.py
86,87
85,91
get
LogoutHandler
87,91
87,91
class LogoutHandler(BaseHandler): def get(self): FILL_FUNC_BODY
class LogoutHandler(BaseHandler): def get(self): FILL_FUNC_BODY
self.clear_cookie("user") self.redirect("/")
self.clear_cookie("user") self.redirect("/")
2
26
25
51
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
"""Demo app for GoogleOAuth2Mixin Recommended usage: - Register an app with Google following the instructions at https://www.tornadoweb.org/en/stable/auth.html#tornado.auth.GoogleOAuth2Mixin - Use "http://localhost:8888/auth/google" as the redirect URI. - Create a file in this directory called main.cfg, containing t...
26,748
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/helloworld/helloworld.py
30,31
1,40
main
31,38
31,38
#!/usr/bin/env python # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
#!/usr/bin/env python # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
tornado.options.parse_command_line() application = tornado.web.Application([(r"/", MainHandler)]) http_server = tornado.httpserver.HTTPServer(application) http_server.listen(options.port) await asyncio.Event().wait()
tornado.options.parse_command_line() application = tornado.web.Application([(r"/", MainHandler)]) http_server = tornado.httpserver.HTTPServer(application) http_server.listen(options.port) await asyncio.Event().wait()
11
278
82
360
#!/usr/bin/env python # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
#!/usr/bin/env python # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
26,749
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/helloworld/helloworld.py
26,27
25,30
get
MainHandler
27,30
27,30
class MainHandler(tornado.web.RequestHandler): def get(self): FILL_FUNC_BODY
class MainHandler(tornado.web.RequestHandler): def get(self): FILL_FUNC_BODY
self.write("Hello, world")
self.write("Hello, world")
2
31
15
46
#!/usr/bin/env python # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
#!/usr/bin/env python # # Copyright 2009 Facebook # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or a...
26,750
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/tcpecho/client.py
12,13
1,23
send_message
13,20
13,20
#!/usr/bin/env python import asyncio from tornado.tcpclient import TCPClient from tornado.options import options, define define("host", default="localhost", help="TCP server host") define("port", default=9888, help="TCP port to connect to") define("message", default="ping", help="Message to send") async def send_me...
#!/usr/bin/env python import asyncio from tornado.tcpclient import TCPClient from tornado.options import options, define define("host", default="localhost", help="TCP server host") define("port", default=9888, help="TCP port to connect to") define("message", default="ping", help="Message to send") async def send_me...
stream = await TCPClient().connect(options.host, options.port) await stream.write((options.message + "\n").encode()) print("Sent to server:", options.message) reply = await stream.read_until(b"\n") print("Response from server:", reply.decode().strip())
stream = await TCPClient().connect(options.host, options.port) await stream.write((options.message + "\n").encode()) print("Sent to server:", options.message) reply = await stream.read_until(b"\n") print("Response from server:", reply.decode().strip())
21
142
87
229
#!/usr/bin/env python import asyncio from tornado.tcpclient import TCPClient from tornado.options import options, define define("host", default="localhost", help="TCP server host") define("port", default=9888, help="TCP port to connect to") define("message", default="ping", help="Message to send") async def send_me...
#!/usr/bin/env python import asyncio from tornado.tcpclient import TCPClient from tornado.options import options, define define("host", default="localhost", help="TCP server host") define("port", default=9888, help="TCP port to connect to") define("message", default="ping", help="Message to send") async def send_me...
26,751
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado
/home/hieuvd/dung_repo/raw/stars_01/tornadoweb_tornado/tornado/demos/tcpecho/server.py
31,32
1,41
main
32,39
32,39
#!/usr/bin/env python import asyncio import logging from tornado import gen from tornado.iostream import StreamClosedError from tornado.tcpserver import TCPServer from tornado.options import options, define define("port", default=9888, help="TCP port to listen on") logger = logging.getLogger(__name__) class EchoSer...
#!/usr/bin/env python import asyncio import logging from tornado import gen from tornado.iostream import StreamClosedError from tornado.tcpserver import TCPServer from tornado.options import options, define define("port", default=9888, help="TCP port to listen on") logger = logging.getLogger(__name__) class EchoSer...
options.parse_command_line() logger.info("Listening on TCP port %d", options.port) server = EchoServer() server.listen(options.port) await asyncio.Event().wait()
options.parse_command_line() logger.info("Listening on TCP port %d", options.port) server = EchoServer() server.listen(options.port) await asyncio.Event().wait()
13
279
65
344
#!/usr/bin/env python import asyncio import logging from tornado import gen from tornado.iostream import StreamClosedError from tornado.tcpserver import TCPServer from tornado.options import options, define define("port", default=9888, help="TCP port to listen on") logger = logging.getLogger(__name__) class EchoSer...
#!/usr/bin/env python import asyncio import logging from tornado import gen from tornado.iostream import StreamClosedError from tornado.tcpserver import TCPServer from tornado.options import options, define define("port", default=9888, help="TCP port to listen on") logger = logging.getLogger(__name__) class EchoSer...