1515@section ("micropython-stubber" )
1616class StubberConfig (Config ):
1717 "stubber configuration class"
18- stub_path = key (key_name = "stub-path" , cast = Path , required = False , default = Path ("./stubs" ))
19- "a Path to the stubs directory"
18+ # legacy
19+ # stub_path = key(key_name="stub-path", cast=Path, required=False, default=Path("./stubs"))
20+ # "a Path to the stubs directory"
21+
2022 # relative to stubs folder
2123 fallback_path = key (key_name = "fallback-path" , cast = Path , required = False , default = Path ("typings/fallback" ))
2224 "a Path to the fallback stubs directory"
@@ -32,24 +34,8 @@ class StubberConfig(Config):
3234 mpy_lib_path = key (key_name = "mpy-lib-path" , cast = Path , required = False , default = Path ("micropython-lib" ))
3335 "a Path to the micropython-lib folder in the repos directory"
3436
35- # mpy_stubs_repo_path = key(key_name="mpy-stubs-repo-path", cast=Path, required=False, default=Path("./micropython-stubs"))
36- # "a Path to the micropython-stubs folder in the repos directory"
37-
38- publish_path = key (
39- key_name = "publish-path" ,
40- cast = Path ,
41- required = False ,
42- default = Path ("./repos/micropython-stubs/publish" ),
43- )
44- "A Path to the folder where all stub publication artifacts are stored"
45-
46- template_path = key (
47- key_name = "template-path" ,
48- cast = Path ,
49- required = False ,
50- default = Path ("./repos/micropython-stubs/publish/template" ),
51- )
52- "a Path to the publication folder that has the template files"
37+ mpy_stubs_path = key (key_name = "mpy-stubs-path" , cast = Path , required = False , default = Path ("micropython-stubs" ))
38+ "a Path to the micropython-stubs folder in the repos directory (or current directory)"
5339
5440 stable_version = key (key_name = "stable-version" , cast = str , required = False , default = "1.20.0" )
5541
@@ -66,25 +52,33 @@ class StubberConfig(Config):
6652 BLOCKED_PORTS = ["minimal" , "bare-arm" ]
6753 "ports that should be ignored as a source of stubs"
6854
69- # def __init__(self):
70- # super().__init__()
71- # self.update_versions()
55+ @property
56+ def stub_path (self ) -> Path :
57+ "return the stubs path in the microypthon-stubs repo"
58+ return self .mpy_stubs_path / "stubs"
59+
60+ @property
61+ def publish_path (self ) -> Path :
62+ "return the stubs path in the microypthon-stubs repo"
63+ return self .mpy_stubs_path / "publish"
7264
73- # def update_versions(self):
74- # try:
75- # self.ALL_VERSIONS = git.get_tags(self.mpy_path, minver="v1.17")
76- # except Exception:
77- # self.ALL_VERSIONS = ["1.17", "1.18", "1.19", "1.19.1"]
78- # self.STABLE_VERSION = self.ALL_VERSIONS[-1]
65+ @property
66+ def template_path (self ) -> Path :
67+ "return the stubs path in the microypthon-stubs repo"
68+ return self .mpy_stubs_path / "publish" / "template"
7969
8070 def post_read_hook (self ) -> dict :
8171 config_updates = {}
8272 # relative to stubs
83- config_updates .update (fallback_path = self .stub_path / self .fallback_path )
73+ # config_updates.update(fallback_path=self.stub_path / self.fallback_path)
8474
8575 # relative to repo path
8676 config_updates .update (mpy_path = self .repo_path / self .mpy_path )
8777 config_updates .update (mpy_lib_path = self .repo_path / self .mpy_lib_path )
78+ if self .mpy_stubs_path .is_absolute () or self .mpy_stubs_path == Path ("." ):
79+ config_updates .update (mpy_stubs_path = self .mpy_stubs_path )
80+ else :
81+ config_updates .update (mpy_stubs_path = self .repo_path / self .mpy_stubs_path )
8882 # read the versions from the git tags
8983 all_versions = []
9084 try :
0 commit comments