Skip to content

Commit d02f25c

Browse files
committed
Fix searching for version: in shard.yml files
1 parent d452ec3 commit d02f25c

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

mkdocstrings/handlers/crystal/collector.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,17 +112,18 @@ def substitute(self, location: DocLocation) -> str:
112112
)
113113

114114
@property
115-
def shard_version(self):
115+
def shard_version(self) -> str:
116116
return self._shard_version(os.path.dirname(self.src_path))
117117

118118
@classmethod
119119
@functools.lru_cache(maxsize=None)
120-
def _shard_version(cls, path: str):
120+
def _shard_version(cls, path: str) -> str:
121121
file_path = _find_above(path, "shard.yml")
122122
with open(file_path, "rb") as f:
123123
m = re.search(rb"^version: *([\S+]+)", f.read(), flags=re.MULTILINE)
124124
if not m:
125125
raise PluginError(f"`version:` not found in {file_path!r}")
126+
return m[1].decode()
126127

127128

128129
def _find_above(path: str, filename: str) -> str:
@@ -143,7 +144,7 @@ def crystal_version(self) -> str:
143144
).rstrip()
144145

145146
@cached_property
146-
def crystal_src(self):
147+
def crystal_src(self) -> str:
147148
out = subprocess.check_output(["crystal", "env", "CRYSTAL_PATH"], text=True).rstrip()
148149
for path in out.split(os.pathsep):
149150
if os.path.isfile(os.path.join(path, "prelude.cr")):

0 commit comments

Comments
 (0)