1414
1515import dataclasses as _dataclasses
1616import itertools as _itertools
17- from typing import Self
17+ from typing import Self , assert_never , overload
1818
1919import nox as _nox
2020
21+ from .._core import RepositoryType
2122from . import util as _util
2223
2324
@@ -177,6 +178,7 @@ def get() -> Config:
177178 return _config
178179
179180
181+ @overload
180182def configure (conf : Config , / , * , import_default_sessions : bool = True ) -> None :
181183 """Configure nox using the provided configuration.
182184
@@ -186,10 +188,63 @@ def configure(conf: Config, /, *, import_default_sessions: bool = True) -> None:
186188 This is only necessary if you want to avoid using the default provided
187189 sessions and use your own.
188190 """
191+
192+
193+ @overload
194+ def configure (
195+ repo_type : RepositoryType , / , * , import_default_sessions : bool = True
196+ ) -> None :
197+ """Configure nox using the provided repository type.
198+
199+ Args:
200+ repo_type: The repository type to use to configure nox. This will use the
201+ default configuration in [`frequenz.repo.config.nox.default`][] for that
202+ type of repository.
203+ import_default_sessions: Whether to import the default sessions or not.
204+ This is only necessary if you want to avoid using the default provided
205+ sessions and use your own.
206+ """
207+
208+
209+ def configure (
210+ conf : Config | RepositoryType , / , * , import_default_sessions : bool = True
211+ ) -> None :
212+ """Configure nox using the provided configuration or repository type.
213+
214+ Args:
215+ conf: The configuration to use to configure nox, or the repository type to use
216+ to configure nox. The later will use the default configuration in
217+ [`frequenz.repo.config.nox.default`][] for that type of repository.
218+ import_default_sessions: Whether to import the default sessions or not.
219+ This is only necessary if you want to avoid using the default provided
220+ sessions and use your own.
221+ """
222+ global _config # pylint: disable=global-statement
223+
189224 # We need to make sure sessions are imported, otherwise they won't be visible to nox.
190225 if import_default_sessions :
191226 # pylint: disable=import-outside-toplevel,cyclic-import
192227 from . import session as _
193- global _config # pylint: disable=global-statement
194- _config = conf
228+
229+ match conf :
230+ case Config ():
231+ _config = conf
232+ case RepositoryType () as repo_type :
233+ # pylint: disable=import-outside-toplevel,cyclic-import
234+ from . import default
235+
236+ match repo_type :
237+ case RepositoryType .ACTOR :
238+ _config = default .actor_config
239+ case RepositoryType .API :
240+ _config = default .api_config
241+ case RepositoryType .APP :
242+ _config = default .app_config
243+ case RepositoryType .LIB :
244+ _config = default .lib_config
245+ case RepositoryType .MODEL :
246+ _config = default .model_config
247+ case _ as unhandled :
248+ assert_never (unhandled )
249+
195250 _nox .options .sessions = _config .sessions
0 commit comments