File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 1
1
import os
2
+ import sys
2
3
from itertools import chain
3
4
from pathlib import PurePath
4
5
from urllib import request
@@ -90,19 +91,22 @@ def notebook_path(return_env=False):
90
91
logger .warning ("Can not import get_ipython." )
91
92
return None
92
93
94
+ # vs code specific
95
+ if "__main__" in sys .modules :
96
+ main_module = sys .modules ["__main__" ]
97
+ if hasattr (main_module , "__vsc_ipynb_file__" ):
98
+ nb_path = main_module .__vsc_ipynb_file__
99
+ return (
100
+ (nb_path , "vs_code" if env is None else env ) if return_env else nb_path
101
+ )
102
+
93
103
ipython_instance = get_ipython ()
94
104
95
105
# not in an ipython kernel
96
106
if ipython_instance is None :
97
107
logger .warning ("The IPython instance is empty." )
98
108
return None
99
109
100
- # vs code specific
101
- user_ns = ipython_instance .__dict__ .get ("user_ns" , {})
102
- if "__vsc_ipynb_file__" in user_ns :
103
- nb_path = PurePath (user_ns ["__vsc_ipynb_file__" ])
104
- return (nb_path , "vs_code" if env is None else env ) if return_env else nb_path
105
-
106
110
config = ipython_instance .config
107
111
# not in a jupyter notebook
108
112
if "IPKernelApp" not in config :
Original file line number Diff line number Diff line change 1
1
import nox
2
2
from laminci .nox import build_docs , run_pre_commit , run_pytest
3
3
4
- nox .options .default_backend = "none"
5
-
6
4
7
5
@nox .session
8
6
def lint (session : nox .Session ) -> None :
You can’t perform that action at this time.
0 commit comments