Skip to content
Myr

⬆️ Upgrade coverage and configs (#769)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sebastián Ramírez · committed by GitHub · parent 2d4c4c9 · Browse files · 23 files+59 added−60 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

23 files+59 added−60 removed

  • tests:+18 added−18 removed
  • other:+41 added−42 removed

23 files+59 added−60 removed

modified:scripts/test.sh+1 added-1 removed
modified:tests/test_completion/test_completion_install.py+2 added-2 removed
70 unmodified lines
7172def test_completion_install_zsh():73 completion_path: Path = Path.home() / ".zshrc"74 text = ""75 if not completion_path.is_file(): # pragma: nocover75 if not completion_path.is_file(): # pragma: no cover76 completion_path.write_text('echo "custom .zshrc"')77 if completion_path.is_file():78 text = completion_path.read_text()79 result = subprocess.run(
67 unmodified lines
147 Path.home() / ".config/powershell/Microsoft.PowerShell_profile.ps1"148 )149 completion_path_bytes = f"{completion_path}\n".encode("windows-1252")150 text = ""151 if completion_path.is_file(): # pragma: nocover151 if completion_path.is_file(): # pragma: no cover152 text = completion_path.read_text()153154 with mock.patch.object(155 shellingham, "detect_shell", return_value=("pwsh", "/usr/bin/pwsh")
19 unmodified lines
modified:tests/test_completion/test_completion.py+1 added-1 removed
21 unmodified lines
2223def test_install_completion():24 bash_completion_path: Path = Path.home() / ".bashrc"25 text = ""26 if bash_completion_path.is_file(): # pragma: nocover26 if bash_completion_path.is_file(): # pragma: no cover27 text = bash_completion_path.read_text()28 result = subprocess.run(29 [30 "bash",
135 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial002_an.py+1 added-1 removed
13 unmodified lines
141516def test_main(tmpdir):17 config_file = Path(tmpdir) / "config.txt"18 if config_file.exists(): # pragma no cover18 if config_file.exists(): # pragma: no cover19 config_file.unlink()20 result = runner.invoke(app, ["--config", f"{config_file}"])21 text = config_file.read_text()22 config_file.unlink()
12 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py+1 added-1 removed
13 unmodified lines
141516def test_main(tmpdir):17 config_file = Path(tmpdir) / "config.txt"18 if config_file.exists(): # pragma no cover18 if config_file.exists(): # pragma: no cover19 config_file.unlink()20 result = runner.invoke(app, ["--config", f"{config_file}"])21 text = config_file.read_text()22 config_file.unlink()
12 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py+1 added-1 removed
13 unmodified lines
141516def test_main(tmpdir):17 binary_file = Path(tmpdir) / "config.txt"18 if binary_file.exists(): # pragma no cover18 if binary_file.exists(): # pragma: no cover19 binary_file.unlink()20 result = runner.invoke(app, ["--file", f"{binary_file}"])21 text = binary_file.read_text()22 binary_file.unlink()
13 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py+1 added-1 removed
13 unmodified lines
141516def test_main(tmpdir):17 binary_file = Path(tmpdir) / "config.txt"18 if binary_file.exists(): # pragma no cover18 if binary_file.exists(): # pragma: no cover19 binary_file.unlink()20 result = runner.invoke(app, ["--file", f"{binary_file}"])21 text = binary_file.read_text()22 binary_file.unlink()
13 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial005_an.py+1 added-1 removed
13 unmodified lines
141516def test_main(tmpdir):17 config_file = Path(tmpdir) / "config.txt"18 if config_file.exists(): # pragma no cover18 if config_file.exists(): # pragma: no cover19 config_file.unlink()20 config_file.write_text("")21 result = runner.invoke(app, ["--config", f"{config_file}"])22 result = runner.invoke(app, ["--config", f"{config_file}"])
15 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py+1 added-1 removed
13 unmodified lines
141516def test_main(tmpdir):17 config_file = Path(tmpdir) / "config.txt"18 if config_file.exists(): # pragma no cover18 if config_file.exists(): # pragma: no cover19 config_file.unlink()20 config_file.write_text("")21 result = runner.invoke(app, ["--config", f"{config_file}"])22 result = runner.invoke(app, ["--config", f"{config_file}"])
15 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_path/test_tutorial001_an.py+1 added-1 removed
21 unmodified lines
222324def test_not_exists(tmpdir):25 config_file = Path(tmpdir) / "config.txt"26 if config_file.exists(): # pragma no cover26 if config_file.exists(): # pragma: no cover27 config_file.unlink()28 result = runner.invoke(app, ["--config", f"{config_file}"])29 assert result.exit_code == 030 assert "The config doesn't exist" in result.output
24 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py+1 added-1 removed
21 unmodified lines
222324def test_not_exists(tmpdir):25 config_file = Path(tmpdir) / "config.txt"26 if config_file.exists(): # pragma no cover26 if config_file.exists(): # pragma: no cover27 config_file.unlink()28 result = runner.invoke(app, ["--config", f"{config_file}"])29 assert result.exit_code == 030 assert "The config doesn't exist" in result.output
24 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_path/test_tutorial002_an.py+1 added-1 removed
13 unmodified lines
141516def test_not_exists(tmpdir):17 config_file = Path(tmpdir) / "config.txt"18 if config_file.exists(): # pragma no cover18 if config_file.exists(): # pragma: no cover19 config_file.unlink()20 result = runner.invoke(app, ["--config", f"{config_file}"])21 assert result.exit_code != 022 assert "Invalid value for '--config': File" in result.output
25 unmodified lines
modified:tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py+1 added-1 removed
13 unmodified lines
141516def test_not_exists(tmpdir):17 config_file = Path(tmpdir) / "config.txt"18 if config_file.exists(): # pragma no cover18 if config_file.exists(): # pragma: no cover19 config_file.unlink()20 result = runner.invoke(app, ["--config", f"{config_file}"])21 assert result.exit_code != 022 assert "Invalid value for '--config': File" in result.output
25 unmodified lines
modified:tests/test_others.py+5 added-5 removed
92 unmodified lines
93def test_callback_too_many_parameters():94 app = typer.Typer()9596 def name_callback(ctx, param, val1, val2):97 pass # pragma: nocover97 pass # pragma: no cover9899 @app.command()100 def main(name: str = typer.Option(..., callback=name_callback)):101 pass # pragma: nocover101 pass # pragma: no cover102103 with pytest.raises(click.ClickException) as exc_info:104 runner.invoke(app, ["--name", "Camila"])105 assert (
92 unmodified lines
198def test_autocompletion_too_many_parameters():199 app = typer.Typer()200201 def name_callback(ctx, args, incomplete, val2):202 pass # pragma: nocover202 pass # pragma: no cover203204 @app.command()205 def main(name: str = typer.Option(..., autocompletion=name_callback)):206 pass # pragma: nocover206 pass # pragma: no cover207208 with pytest.raises(click.ClickException) as exc_info:209 runner.invoke(app, ["--name", "Camila"])210 assert exc_info.value.message == "Invalid autocompletion callback parameters: val2"
24 unmodified lines
235 app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})236237 @app.command()238 def main(name: str):239 pass # pragma: nocover239 pass # pragma: no cover240241 result = runner.invoke(app, ["main", "-h"])242 assert "Show this message and exit." in result.stdout243
17 unmodified lines
modified:typer/_completion_classes.py+1 added-1 removed
15 unmodified lines
16)1718try:19 import shellingham20except ImportError: # pragma: nocover20except ImportError: # pragma: no cover21 shellingham = None222324class BashComplete(click.shell_completion.BashComplete):
168 unmodified lines
modified:typer/_completion_shared.py+6 added-6 removed
7 unmodified lines
8import click910try:11 import shellingham12except ImportError: # pragma: nocover12except ImportError: # pragma: no cover13 shellingham = None141516class Shells(str, Enum):
90 unmodified lines
107 if rc_path.is_file():108 rc_content = rc_path.read_text()109 completion_init_lines = [f"source {completion_path}"]110 for line in completion_init_lines:111 if line not in rc_content: # pragma: nocover111 if line not in rc_content: # pragma: no cover112 rc_content += f"\n{line}"113 rc_content += "\n"114 rc_path.write_text(rc_content)115 # Install completion
18 unmodified lines
134 "zstyle ':completion:*' menu select",135 "fpath+=~/.zfunc",136 ]137 for line in completion_init_lines:138 if line not in zshrc_content: # pragma: nocover138 if line not in zshrc_content: # pragma: no cover139 zshrc_content += f"\n{line}"140 zshrc_content += "\n"141 zshrc_path.write_text(zshrc_content)142 # Install completion under ~/.zfunc/
32 unmodified lines
175 [shell, "-NoProfile", "-Command", "echo", "$profile"],176 check=True,177 stdout=subprocess.PIPE,178 )179 if result.returncode != 0: # pragma: nocover179 if result.returncode != 0: # pragma: no cover180 click.echo("Couldn't get PowerShell user profile", err=True)181 raise click.exceptions.Exit(result.returncode)182 path_str = ""183 if isinstance(result.stdout, str): # pragma: nocover183 if isinstance(result.stdout, str): # pragma: no cover184 path_str = result.stdout185 if isinstance(result.stdout, bytes):186 try:187 # PowerShell would be predominant in Windows188 path_str = result.stdout.decode("windows-1252")189 except UnicodeDecodeError: # pragma: nocover189 except UnicodeDecodeError: # pragma: no cover190 try:191 path_str = result.stdout.decode("utf8")192 except UnicodeDecodeError:193 click.echo("Couldn't decode the path automatically", err=True)
47 unmodified lines
modified:typer/completion.py+5 added-5 removed
10 unmodified lines
11from .utils import get_params_from_function1213try:14 import shellingham15except ImportError: # pragma: nocover15except ImportError: # pragma: no cover16 shellingham = None171819_click_patched = False
13 unmodified lines
333435def install_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Any:36 if not value or ctx.resilient_parsing:37 return value # pragma no cover37 return value # pragma: no cover38 if isinstance(value, str):39 shell, path = install(shell=value)40 else:41 shell, path = install()
3 unmodified lines
454647def show_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Any:48 if not value or ctx.resilient_parsing:49 return value # pragma no cover49 return value # pragma: no cover50 prog_name = ctx.find_root().info_name51 assert prog_name52 complete_var = "_{}_COMPLETE".format(prog_name.replace("-", "_").upper())53 shell = ""
27 unmodified lines
81 expose_value=False,82 help="Show completion for the current shell, to copy it or customize the installation.",83 ),84) -> Any:85 pass # pragma no cover85 pass # pragma: no cover868788def _install_completion_no_auto_placeholder_function(89 install_completion: Shells = Option(
8 unmodified lines
98 expose_value=False,99 help="Show completion for the specified shell, to copy it or customize the installation.",100 ),101) -> Any:102 pass # pragma no cover102 pass # pragma: no cover103104105# Re-implement Click's shell_complete to add error message with:106# Invalid completion instruction
43 unmodified lines
modified:typer/core.py+1 added-1 removed
34 unmodified lines
35 import rich3637 from . import rich_utils3839except ImportError: # pragma: nocover39except ImportError: # pragma: no cover40 rich = None # type: ignore4142MarkupMode = Literal["markdown", "rich", None]43
697 unmodified lines
modified:typer/main.py+4 added-4 removed
41 unmodified lines
42 from rich.traceback import Traceback4344 console_stderr = Console(stderr=True)4546except ImportError: # pragma: nocover46except ImportError: # pragma: no cover47 rich = None # type: ignore4849_original_except_hook = sys.excepthook50_typer_developer_exception_attr_name = "__typer_developer_exception__"
318 unmodified lines
369 click_command.params.append(click_show_param)370 return click_command371 raise RuntimeError(372 "Could not get a command for this Typer instance"373 ) # pragma no cover373 ) # pragma: no cover374375376def get_group_name(typer_info: TyperInfo) -> Optional[str]:377 if typer_info.callback:
402 unmodified lines
780 return click.Choice(781 [item.value for item in annotation],782 case_sensitive=parameter_info.case_sensitive,783 )784 raise RuntimeError(f"Type not yet supported: {annotation}") # pragma no cover784 raise RuntimeError(f"Type not yet supported: {annotation}") # pragma: no cover785786787def lenient_issubclass(788 cls: Any, class_or_tuple: Union[AnyType, Tuple[AnyType, ...]]
159 unmodified lines
948 rich_help_panel=parameter_info.rich_help_panel,949 ),950 convertor,951 )952 raise AssertionError("A click.Parameter should be returned") # pragma no cover952 raise AssertionError("A click.Parameter should be returned") # pragma: no cover953954955def get_param_callback(956 *,
107 unmodified lines
deleted:.coveragerc-23 removed
1[run]23source =4 typer5 tests6 docs_src78omit =9 typer/_typing.py1011parallel = True12context = '${CONTEXT}'1314[report]15precision = 216exclude_lines =17 pragma: no cover18 pragma: nocover19 pragma no cover20 raise NotImplementedError21 raise NotImplemented22 @overload23 if TYPE_CHECKING:
modified:.gitignore+1 added
9 unmodified lines
10.coverage11htmlcov12.pytest_cache13coverage.xml14.coverage*
modified:pyproject.toml+21 added
74 unmodified lines
75 # For pytest-xdist76 'ignore::DeprecationWarning:xdist',77]7879[tool.coverage.run]80parallel = true81data_file = "coverage/.coverage"82source = [83 "docs_src",84 "tests",85 "typer"86]87omit = [88 "typer/_typing.py"89]90context = '${CONTEXT}'9192[tool.coverage.report]93exclude_lines = [94 "pragma: no cover",95 "@overload",96 'if __name__ == "__main__":',97 "if TYPE_CHECKING:",98]99100[tool.mypy]101strict = true102103[[tool.mypy.overrides]]
58 unmodified lines
modified:requirements-tests.txt+1 added-1 removed
1-e .[all]23pytest >=4.4.0,<8.0.04pytest-cov >=2.10.0,<5.0.05coverage[toml] >=6.2,<7.05coverage[toml] >=6.2,<8.06pytest-xdist >=1.32.0,<4.0.07pytest-sugar >=0.9.4,<0.10.08mypy ==1.4.19ruff ==0.2.0