File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -101,14 +101,21 @@ impl SourceKind {
101101 /// Read the [`SourceKind`] from the given path. Returns `None` if the source is not a Python
102102 /// source file.
103103 pub fn from_path ( path : & Path , source_type : PySourceType ) -> Result < Option < Self > , SourceError > {
104- if source_type. is_ipynb ( ) {
105- let notebook = Notebook :: from_path ( path) ?;
106- Ok ( notebook
107- . is_python_notebook ( )
108- . then_some ( Self :: IpyNotebook ( Box :: new ( notebook) ) ) )
109- } else {
110- let contents = std:: fs:: read_to_string ( path) ?;
111- Ok ( Some ( Self :: Python ( contents) ) )
104+ match source_type {
105+ PySourceType :: Ipynb => {
106+ let notebook = Notebook :: from_path ( path) ?;
107+ Ok ( notebook
108+ . is_python_notebook ( )
109+ . then_some ( Self :: IpyNotebook ( Box :: new ( notebook) ) ) )
110+ }
111+ PySourceType :: Markdown => {
112+ let contents = std:: fs:: read_to_string ( path) ?;
113+ Ok ( Some ( Self :: Markdown ( contents) ) )
114+ }
115+ PySourceType :: Python | PySourceType :: Stub => {
116+ let contents = std:: fs:: read_to_string ( path) ?;
117+ Ok ( Some ( Self :: Python ( contents) ) )
118+ }
112119 }
113120 }
114121
You can’t perform that action at this time.
0 commit comments