@@ -105,7 +105,7 @@ def is_used(self) -> bool:
105105 """Whether the tool is being used in the current project.
106106
107107 Three heuristics are used by default:
108- 1. Whether any of the tool's characteristic dev dependencies are in the project.
108+ 1. Whether any of the tool's characteristic dependencies are in the project.
109109 2. Whether any of the tool's managed files are in the project.
110110 3. Whether any of the tool's managed config file sections are present.
111111 """
@@ -118,19 +118,7 @@ def is_used(self) -> bool:
118118
119119 if not _is_used :
120120 try :
121- _is_used = any (
122- is_dep_in_any_group (dep )
123- for dep in self .get_dev_deps (unconditional = True )
124- )
125- except FileDecodeError as err :
126- decode_err_by_name [err .name ] = err
127-
128- if not _is_used :
129- try :
130- _is_used = any (
131- is_dep_in_any_group (dep )
132- for dep in self .get_test_deps (unconditional = True )
133- )
121+ _is_used = self .is_declared_as_dep ()
134122 except FileDecodeError as err :
135123 decode_err_by_name [err .name ] = err
136124
@@ -148,6 +136,29 @@ def is_used(self) -> bool:
148136
149137 return _is_used
150138
139+ def is_declared_as_dep (self ) -> bool :
140+ """Whether the tool is declared as a dependency in the project.
141+
142+ This is inferred based on whether any of the tools characteristic dependencies
143+ are declared in the project.
144+ """
145+ # N.B. currently doesn't check core dependencies nor extras.
146+ # Only PEP735 dependency groups.
147+ # See https://github.com/usethis-python/usethis-python/issues/809
148+ _is_declared = False
149+
150+ _is_declared = any (
151+ is_dep_in_any_group (dep ) for dep in self .get_dev_deps (unconditional = True )
152+ )
153+
154+ if not _is_declared :
155+ _is_declared = any (
156+ is_dep_in_any_group (dep )
157+ for dep in self .get_test_deps (unconditional = True )
158+ )
159+
160+ return _is_declared
161+
151162 def add_dev_deps (self ) -> None :
152163 add_deps_to_group (self .get_dev_deps (), "dev" )
153164
0 commit comments