Skip to content

Commit 71bdae1

Browse files
authored
⬆️ Upgrade coverage and configs (#769)
1 parent 2d4c4c9 commit 71bdae1

23 files changed

+59
-60
lines changed

.coveragerc

-23
This file was deleted.

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ site
1111
htmlcov
1212
.pytest_cache
1313
coverage.xml
14+
.coverage*

pyproject.toml

+21
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ filterwarnings = [
7676
'ignore::DeprecationWarning:xdist',
7777
]
7878

79+
[tool.coverage.run]
80+
parallel = true
81+
data_file = "coverage/.coverage"
82+
source = [
83+
"docs_src",
84+
"tests",
85+
"typer"
86+
]
87+
omit = [
88+
"typer/_typing.py"
89+
]
90+
context = '${CONTEXT}'
91+
92+
[tool.coverage.report]
93+
exclude_lines = [
94+
"pragma: no cover",
95+
"@overload",
96+
'if __name__ == "__main__":',
97+
"if TYPE_CHECKING:",
98+
]
99+
79100
[tool.mypy]
80101
strict = true
81102

requirements-tests.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pytest >=4.4.0,<8.0.0
44
pytest-cov >=2.10.0,<5.0.0
5-
coverage[toml] >=6.2,<7.0
5+
coverage[toml] >=6.2,<8.0
66
pytest-xdist >=1.32.0,<4.0.0
77
pytest-sugar >=0.9.4,<0.10.0
88
mypy ==1.4.1

scripts/test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ export TERMINAL_WIDTH=3000
99
export _TYPER_FORCE_DISABLE_TERMINAL=1
1010
bash ./scripts/test-files.sh
1111
# It seems xdist-pytest ensures modified sys.path to import relative modules in examples keeps working
12-
pytest --cov-config=.coveragerc --cov --cov-report=term-missing -o console_output_style=progress --numprocesses=auto ${@}
12+
pytest --cov --cov-report=term-missing -o console_output_style=progress --numprocesses=auto ${@}

tests/test_completion/test_completion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_show_completion():
2323
def test_install_completion():
2424
bash_completion_path: Path = Path.home() / ".bashrc"
2525
text = ""
26-
if bash_completion_path.is_file(): # pragma: nocover
26+
if bash_completion_path.is_file(): # pragma: no cover
2727
text = bash_completion_path.read_text()
2828
result = subprocess.run(
2929
[

tests/test_completion/test_completion_install.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_completion_install_bash():
7272
def test_completion_install_zsh():
7373
completion_path: Path = Path.home() / ".zshrc"
7474
text = ""
75-
if not completion_path.is_file(): # pragma: nocover
75+
if not completion_path.is_file(): # pragma: no cover
7676
completion_path.write_text('echo "custom .zshrc"')
7777
if completion_path.is_file():
7878
text = completion_path.read_text()
@@ -148,7 +148,7 @@ def test_completion_install_powershell():
148148
)
149149
completion_path_bytes = f"{completion_path}\n".encode("windows-1252")
150150
text = ""
151-
if completion_path.is_file(): # pragma: nocover
151+
if completion_path.is_file(): # pragma: no cover
152152
text = completion_path.read_text()
153153

154154
with mock.patch.object(

tests/test_others.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ def test_callback_too_many_parameters():
9494
app = typer.Typer()
9595

9696
def name_callback(ctx, param, val1, val2):
97-
pass # pragma: nocover
97+
pass # pragma: no cover
9898

9999
@app.command()
100100
def main(name: str = typer.Option(..., callback=name_callback)):
101-
pass # pragma: nocover
101+
pass # pragma: no cover
102102

103103
with pytest.raises(click.ClickException) as exc_info:
104104
runner.invoke(app, ["--name", "Camila"])
@@ -199,11 +199,11 @@ def test_autocompletion_too_many_parameters():
199199
app = typer.Typer()
200200

201201
def name_callback(ctx, args, incomplete, val2):
202-
pass # pragma: nocover
202+
pass # pragma: no cover
203203

204204
@app.command()
205205
def main(name: str = typer.Option(..., autocompletion=name_callback)):
206-
pass # pragma: nocover
206+
pass # pragma: no cover
207207

208208
with pytest.raises(click.ClickException) as exc_info:
209209
runner.invoke(app, ["--name", "Camila"])
@@ -236,7 +236,7 @@ def test_context_settings_inheritance_single_command():
236236

237237
@app.command()
238238
def main(name: str):
239-
pass # pragma: nocover
239+
pass # pragma: no cover
240240

241241
result = runner.invoke(app, ["main", "-h"])
242242
assert "Show this message and exit." in result.stdout

tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_main(tmpdir):
1717
config_file = Path(tmpdir) / "config.txt"
18-
if config_file.exists(): # pragma no cover
18+
if config_file.exists(): # pragma: no cover
1919
config_file.unlink()
2020
result = runner.invoke(app, ["--config", f"{config_file}"])
2121
text = config_file.read_text()

tests/test_tutorial/test_parameter_types/test_file/test_tutorial002_an.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_main(tmpdir):
1717
config_file = Path(tmpdir) / "config.txt"
18-
if config_file.exists(): # pragma no cover
18+
if config_file.exists(): # pragma: no cover
1919
config_file.unlink()
2020
result = runner.invoke(app, ["--config", f"{config_file}"])
2121
text = config_file.read_text()

tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_main(tmpdir):
1717
binary_file = Path(tmpdir) / "config.txt"
18-
if binary_file.exists(): # pragma no cover
18+
if binary_file.exists(): # pragma: no cover
1919
binary_file.unlink()
2020
result = runner.invoke(app, ["--file", f"{binary_file}"])
2121
text = binary_file.read_text()

tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_main(tmpdir):
1717
binary_file = Path(tmpdir) / "config.txt"
18-
if binary_file.exists(): # pragma no cover
18+
if binary_file.exists(): # pragma: no cover
1919
binary_file.unlink()
2020
result = runner.invoke(app, ["--file", f"{binary_file}"])
2121
text = binary_file.read_text()

tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_main(tmpdir):
1717
config_file = Path(tmpdir) / "config.txt"
18-
if config_file.exists(): # pragma no cover
18+
if config_file.exists(): # pragma: no cover
1919
config_file.unlink()
2020
config_file.write_text("")
2121
result = runner.invoke(app, ["--config", f"{config_file}"])

tests/test_tutorial/test_parameter_types/test_file/test_tutorial005_an.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_main(tmpdir):
1717
config_file = Path(tmpdir) / "config.txt"
18-
if config_file.exists(): # pragma no cover
18+
if config_file.exists(): # pragma: no cover
1919
config_file.unlink()
2020
config_file.write_text("")
2121
result = runner.invoke(app, ["--config", f"{config_file}"])

tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_no_path(tmpdir):
2323

2424
def test_not_exists(tmpdir):
2525
config_file = Path(tmpdir) / "config.txt"
26-
if config_file.exists(): # pragma no cover
26+
if config_file.exists(): # pragma: no cover
2727
config_file.unlink()
2828
result = runner.invoke(app, ["--config", f"{config_file}"])
2929
assert result.exit_code == 0

tests/test_tutorial/test_parameter_types/test_path/test_tutorial001_an.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_no_path(tmpdir):
2323

2424
def test_not_exists(tmpdir):
2525
config_file = Path(tmpdir) / "config.txt"
26-
if config_file.exists(): # pragma no cover
26+
if config_file.exists(): # pragma: no cover
2727
config_file.unlink()
2828
result = runner.invoke(app, ["--config", f"{config_file}"])
2929
assert result.exit_code == 0

tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_not_exists(tmpdir):
1717
config_file = Path(tmpdir) / "config.txt"
18-
if config_file.exists(): # pragma no cover
18+
if config_file.exists(): # pragma: no cover
1919
config_file.unlink()
2020
result = runner.invoke(app, ["--config", f"{config_file}"])
2121
assert result.exit_code != 0

tests/test_tutorial/test_parameter_types/test_path/test_tutorial002_an.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
def test_not_exists(tmpdir):
1717
config_file = Path(tmpdir) / "config.txt"
18-
if config_file.exists(): # pragma no cover
18+
if config_file.exists(): # pragma: no cover
1919
config_file.unlink()
2020
result = runner.invoke(app, ["--config", f"{config_file}"])
2121
assert result.exit_code != 0

typer/_completion_classes.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
try:
1919
import shellingham
20-
except ImportError: # pragma: nocover
20+
except ImportError: # pragma: no cover
2121
shellingham = None
2222

2323

typer/_completion_shared.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
try:
1111
import shellingham
12-
except ImportError: # pragma: nocover
12+
except ImportError: # pragma: no cover
1313
shellingham = None
1414

1515

@@ -108,7 +108,7 @@ def install_bash(*, prog_name: str, complete_var: str, shell: str) -> Path:
108108
rc_content = rc_path.read_text()
109109
completion_init_lines = [f"source {completion_path}"]
110110
for line in completion_init_lines:
111-
if line not in rc_content: # pragma: nocover
111+
if line not in rc_content: # pragma: no cover
112112
rc_content += f"\n{line}"
113113
rc_content += "\n"
114114
rc_path.write_text(rc_content)
@@ -135,7 +135,7 @@ def install_zsh(*, prog_name: str, complete_var: str, shell: str) -> Path:
135135
"fpath+=~/.zfunc",
136136
]
137137
for line in completion_init_lines:
138-
if line not in zshrc_content: # pragma: nocover
138+
if line not in zshrc_content: # pragma: no cover
139139
zshrc_content += f"\n{line}"
140140
zshrc_content += "\n"
141141
zshrc_path.write_text(zshrc_content)
@@ -176,17 +176,17 @@ def install_powershell(*, prog_name: str, complete_var: str, shell: str) -> Path
176176
check=True,
177177
stdout=subprocess.PIPE,
178178
)
179-
if result.returncode != 0: # pragma: nocover
179+
if result.returncode != 0: # pragma: no cover
180180
click.echo("Couldn't get PowerShell user profile", err=True)
181181
raise click.exceptions.Exit(result.returncode)
182182
path_str = ""
183-
if isinstance(result.stdout, str): # pragma: nocover
183+
if isinstance(result.stdout, str): # pragma: no cover
184184
path_str = result.stdout
185185
if isinstance(result.stdout, bytes):
186186
try:
187187
# PowerShell would be predominant in Windows
188188
path_str = result.stdout.decode("windows-1252")
189-
except UnicodeDecodeError: # pragma: nocover
189+
except UnicodeDecodeError: # pragma: no cover
190190
try:
191191
path_str = result.stdout.decode("utf8")
192192
except UnicodeDecodeError:

typer/completion.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
try:
1414
import shellingham
15-
except ImportError: # pragma: nocover
15+
except ImportError: # pragma: no cover
1616
shellingham = None
1717

1818

@@ -34,7 +34,7 @@ def get_completion_inspect_parameters() -> Tuple[ParamMeta, ParamMeta]:
3434

3535
def install_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Any:
3636
if not value or ctx.resilient_parsing:
37-
return value # pragma no cover
37+
return value # pragma: no cover
3838
if isinstance(value, str):
3939
shell, path = install(shell=value)
4040
else:
@@ -46,7 +46,7 @@ def install_callback(ctx: click.Context, param: click.Parameter, value: Any) ->
4646

4747
def show_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Any:
4848
if not value or ctx.resilient_parsing:
49-
return value # pragma no cover
49+
return value # pragma: no cover
5050
prog_name = ctx.find_root().info_name
5151
assert prog_name
5252
complete_var = "_{}_COMPLETE".format(prog_name.replace("-", "_").upper())
@@ -82,7 +82,7 @@ def _install_completion_placeholder_function(
8282
help="Show completion for the current shell, to copy it or customize the installation.",
8383
),
8484
) -> Any:
85-
pass # pragma no cover
85+
pass # pragma: no cover
8686

8787

8888
def _install_completion_no_auto_placeholder_function(
@@ -99,7 +99,7 @@ def _install_completion_no_auto_placeholder_function(
9999
help="Show completion for the specified shell, to copy it or customize the installation.",
100100
),
101101
) -> Any:
102-
pass # pragma no cover
102+
pass # pragma: no cover
103103

104104

105105
# Re-implement Click's shell_complete to add error message with:

typer/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
from . import rich_utils
3838

39-
except ImportError: # pragma: nocover
39+
except ImportError: # pragma: no cover
4040
rich = None # type: ignore
4141

4242
MarkupMode = Literal["markdown", "rich", None]

typer/main.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
console_stderr = Console(stderr=True)
4545

46-
except ImportError: # pragma: nocover
46+
except ImportError: # pragma: no cover
4747
rich = None # type: ignore
4848

4949
_original_except_hook = sys.excepthook
@@ -370,7 +370,7 @@ def get_command(typer_instance: Typer) -> click.Command:
370370
return click_command
371371
raise RuntimeError(
372372
"Could not get a command for this Typer instance"
373-
) # pragma no cover
373+
) # pragma: no cover
374374

375375

376376
def get_group_name(typer_info: TyperInfo) -> Optional[str]:
@@ -781,7 +781,7 @@ def get_click_type(
781781
[item.value for item in annotation],
782782
case_sensitive=parameter_info.case_sensitive,
783783
)
784-
raise RuntimeError(f"Type not yet supported: {annotation}") # pragma no cover
784+
raise RuntimeError(f"Type not yet supported: {annotation}") # pragma: no cover
785785

786786

787787
def lenient_issubclass(
@@ -949,7 +949,7 @@ def get_click_param(
949949
),
950950
convertor,
951951
)
952-
raise AssertionError("A click.Parameter should be returned") # pragma no cover
952+
raise AssertionError("A click.Parameter should be returned") # pragma: no cover
953953

954954

955955
def get_param_callback(

0 commit comments

Comments
 (0)