File tree Expand file tree Collapse file tree
tests/usethis/_ui/interface Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -317,6 +317,7 @@ Currently supported badges:
317317- ` usethis badge pypi ` - [ ![ PyPI Version] ( https://img.shields.io/pypi/v/usethis.svg )] ( https://pypi.python.org/pypi/usethis )
318318- ` usethis badge ruff ` - [ ![ Ruff] ( https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json )] ( https://github.com/astral-sh/ruff )
319319- ` usethis badge socket ` - [ ![ Socket] ( https://badge.socket.dev/pypi/package/usethis )] ( https://socket.dev/pypi/package/usethis/overview )
320+ - ` usethis badge ty ` - [ ![ ty] ( https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ty/main/assets/badge/v0.json )] ( https://github.com/astral-sh/ty )
320321- ` usethis badge usethis ` - [ ![ usethis] ( https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/usethis-python/usethis-python/main/assets/badge/v1.json )] ( https://github.com/usethis-python/usethis-python )
321322- ` usethis badge uv ` - [ ![ uv] ( https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json )] ( https://github.com/astral-sh/uv )
322323
Original file line number Diff line number Diff line change @@ -62,6 +62,12 @@ def get_socket_badge() -> Badge:
6262 )
6363
6464
65+ def get_ty_badge () -> Badge :
66+ return Badge (
67+ markdown = "[](https://github.com/astral-sh/ty)"
68+ )
69+
70+
6571def get_uv_badge () -> Badge :
6672 return Badge (
6773 markdown = "[](https://github.com/astral-sh/uv)"
@@ -83,6 +89,7 @@ def get_badge_order() -> list[Badge]:
8389 get_pypi_badge (),
8490 get_uv_badge (),
8591 get_ruff_badge (),
92+ get_ty_badge (),
8693 get_pre_commit_badge (),
8794 get_usethis_badge (),
8895 get_socket_badge (),
Original file line number Diff line number Diff line change @@ -49,6 +49,20 @@ def ruff(
4949 _badge_effect (get_ruff_badge (), remove = remove , show = show )
5050
5151
52+ @app .command (help = "Add a badge for the ty type checker." )
53+ def ty (
54+ remove : bool = remove_opt ,
55+ offline : bool = offline_opt ,
56+ quiet : bool = quiet_opt ,
57+ show : bool = show_opt ,
58+ ) -> None :
59+ from usethis ._config_file import files_manager
60+ from usethis ._core .badge import get_ty_badge
61+
62+ with usethis_config .set (offline = offline , quiet = quiet ), files_manager ():
63+ _badge_effect (get_ty_badge (), remove = remove , show = show )
64+
65+
5266@app .command (help = "Add a badge for the pre-commit framework." )
5367def pre_commit (
5468 remove : bool = remove_opt ,
Original file line number Diff line number Diff line change @@ -86,6 +86,45 @@ def test_show(self, tmp_path: Path):
8686 assert result .exit_code == 0 , result .output
8787
8888
89+ class TestTy :
90+ def test_add (self , tmp_path : Path ):
91+ # Act
92+ runner = CliRunner ()
93+ with change_cwd (tmp_path ):
94+ result = runner .invoke_safe (app , ["ty" ])
95+
96+ # Assert
97+ assert result .exit_code == 0 , result .output
98+
99+ def test_remove (self , tmp_path : Path ):
100+ # Arrange
101+ (tmp_path / "README.md" ).write_text ("" )
102+
103+ # Act
104+ runner = CliRunner ()
105+ with change_cwd (tmp_path ):
106+ result = runner .invoke_safe (app , ["ty" , "--remove" ])
107+
108+ # Assert
109+ assert result .exit_code == 0 , result .output
110+
111+ def test_show (self , tmp_path : Path ):
112+ # Arrange
113+ (tmp_path / "README.md" ).write_text ("" )
114+
115+ # Act
116+ runner = CliRunner ()
117+ with change_cwd (tmp_path ):
118+ result = runner .invoke_safe (app , ["ty" , "--show" ])
119+
120+ # Assert
121+ assert result .exit_code == 0 , result .output
122+ assert (
123+ result .output
124+ == "[](https://github.com/astral-sh/ty)\n "
125+ )
126+
127+
89128class TestSocket :
90129 def test_add (self , tmp_path : Path ):
91130 # Act
You can’t perform that action at this time.
0 commit comments