GeezerVison is showing github.com — allow_none=False by default for Type and Instance · dhrits/ipython@4c8e425
File treeExpand file treeCollapse file tree Open diff view settings jupyter_qtconsole/console
Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: IPython/config/application.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -174,7 +174,7 @@ def _log_format_changed(self, name, old, new): | 174 | 174 | _log_handler.setFormatter(_log_formatter) | 175 | 175 |
| 176 | 176 |
| 177 | | - log = Instance(logging.Logger) | | 177 | + log = Instance(logging.Logger, allow_none=True) | 178 | 178 | def _log_default(self): | 179 | 179 | """Start logging for this application. | 180 | 180 |
| |
Collapse file Copy file name to clipboardExpand all lines: IPython/config/configurable.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -34,7 +34,7 @@ class MultipleInstanceError(ConfigurableError): | 34 | 34 | class Configurable(HasTraits): | 35 | 35 |
| 36 | 36 | config = Instance(Config, (), {}) | 37 | | - parent = Instance('IPython.config.configurable.Configurable') | | 37 | + parent = Instance('IPython.config.configurable.Configurable', allow_none=True) | 38 | 38 |
| 39 | 39 | def __init__(self, **kwargs): | 40 | 40 | """Create a configurable given a config config. | @@ -372,7 +372,7 @@ class LoggingConfigurable(Configurable): | 372 | 372 | is to get the logger from the currently running Application. | 373 | 373 | """ | 374 | 374 |
| 375 | | - log = Instance('logging.Logger') | | 375 | + log = Instance('logging.Logger', allow_none=True) | 376 | 376 | def _log_default(self): | 377 | 377 | from IPython.utils import log | 378 | 378 | return log.get_logger() | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/alias.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -193,7 +193,7 @@ class AliasManager(Configurable): | 193 | 193 |
| 194 | 194 | default_aliases = List(default_aliases(), config=True) | 195 | 195 | user_aliases = List(default_value=[], config=True) | 196 | | - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | | 196 | + shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | 197 | 197 |
| 198 | 198 | def __init__(self, shell=None, **kwargs): | 199 | 199 | super(AliasManager, self).__init__(shell=shell, **kwargs) | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/application.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -146,7 +146,7 @@ def _ipython_dir_default(self): | 146 | 146 | return d | 147 | 147 |
| 148 | 148 | _in_init_profile_dir = False | 149 | | - profile_dir = Instance(ProfileDir) | | 149 | + profile_dir = Instance(ProfileDir, allow_none=True) | 150 | 150 | def _profile_dir_default(self): | 151 | 151 | # avoid recursion | 152 | 152 | if self._in_init_profile_dir: | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/builtin_trap.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -36,7 +36,8 @@ class __HideBuiltin(object): pass | 36 | 36 |
| 37 | 37 | class BuiltinTrap(Configurable): | 38 | 38 |
| 39 | | - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | | 39 | + shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | | 40 | + allow_none=True) | 40 | 41 |
| 41 | 42 | def __init__(self, shell=None): | 42 | 43 | super(BuiltinTrap, self).__init__(shell=shell, config=None) | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/displayhook.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -29,7 +29,8 @@ class DisplayHook(Configurable): | 29 | 29 | that gets called anytime user code returns a value. | 30 | 30 | """ | 31 | 31 |
| 32 | | - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | | 32 | + shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | | 33 | + allow_none=True) | 33 | 34 | exec_result = Instance('IPython.core.interactiveshell.ExecutionResult', | 34 | 35 | allow_none=True) | 35 | 36 | cull_fraction = Float(0.2) | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/extensions.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -46,7 +46,8 @@ def load_ipython_extension(ipython): | 46 | 46 | is added to ``sys.path`` automatically. | 47 | 47 | """ | 48 | 48 |
| 49 | | - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | | 49 | + shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | | 50 | + allow_none=True) | 50 | 51 |
| 51 | 52 | def __init__(self, shell=None, **kwargs): | 52 | 53 | super(ExtensionManager, self).__init__(shell=shell, **kwargs) | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/history.py +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -443,7 +443,8 @@ class HistoryManager(HistoryAccessor): | 443 | 443 | # Public interface | 444 | 444 |
| 445 | 445 | # An instance of the IPython shell we are attached to | 446 | | - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | | 446 | + shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', | | 447 | + allow_none=True) | 447 | 448 | # Lists to hold processed and raw history. These start with a blank entry | 448 | 449 | # so that we can index them starting from 1 | 449 | 450 | input_hist_parsed = List([""]) | @@ -477,11 +478,12 @@ def _dir_hist_default(self): | 477 | 478 | db_output_cache = List() | 478 | 479 |
| 479 | 480 | # History saving in separate thread | 480 | | - save_thread = Instance('IPython.core.history.HistorySavingThread') | | 481 | + save_thread = Instance('IPython.core.history.HistorySavingThread', | | 482 | + allow_none=True) | 481 | 483 | try: # Event is a function returning an instance of _Event... | 482 | | - save_flag = Instance(threading._Event) | | 484 | + save_flag = Instance(threading._Event, allow_none=True) | 483 | 485 | except AttributeError: # ...until Python 3.3, when it's a class. | 484 | | - save_flag = Instance(threading.Event) | | 486 | + save_flag = Instance(threading.Event, allow_none=True) | 485 | 487 |
| 486 | 488 | # Private interface | 487 | 489 | # Variables used to store the three last inputs from the user. On each new | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/interactiveshell.py +15-15Lines changed: 15 additions & 15 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -295,13 +295,13 @@ class InteractiveShell(SingletonConfigurable): | 295 | 295 | disable_failing_post_execute = CBool(False, config=True, | 296 | 296 | help="Don't call post-execute functions that have failed in the past." | 297 | 297 | ) | 298 | | - display_formatter = Instance(DisplayFormatter) | 299 | | - displayhook_class = Type(DisplayHook) | 300 | | - display_pub_class = Type(DisplayPublisher) | | 298 | + display_formatter = Instance(DisplayFormatter, allow_none=True) | | 299 | + displayhook_class = Type(DisplayHook, allow_none=True) | | 300 | + display_pub_class = Type(DisplayPublisher, allow_none=True) | 301 | 301 | data_pub_class = None | 302 | 302 |
| 303 | 303 | exit_now = CBool(False) | 304 | | - exiter = Instance(ExitAutocall) | | 304 | + exiter = Instance(ExitAutocall, allow_none=True) | 305 | 305 | def _exiter_default(self): | 306 | 306 | return ExitAutocall(self) | 307 | 307 | # Monotonically increasing execution counter | @@ -435,16 +435,16 @@ def _readline_parse_and_bind_changed(self, name, old, new): | 435 | 435 | default_value='Context', config=True) | 436 | 436 |
| 437 | 437 | # Subcomponents of InteractiveShell | 438 | | - alias_manager = Instance('IPython.core.alias.AliasManager') | 439 | | - prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager') | 440 | | - builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap') | 441 | | - display_trap = Instance('IPython.core.display_trap.DisplayTrap') | 442 | | - extension_manager = Instance('IPython.core.extensions.ExtensionManager') | 443 | | - payload_manager = Instance('IPython.core.payload.PayloadManager') | 444 | | - history_manager = Instance('IPython.core.history.HistoryAccessorBase') | 445 | | - magics_manager = Instance('IPython.core.magic.MagicsManager') | 446 | | - | 447 | | - profile_dir = Instance('IPython.core.application.ProfileDir') | | 438 | + alias_manager = Instance('IPython.core.alias.AliasManager', allow_none=True) | | 439 | + prefilter_manager = Instance('IPython.core.prefilter.PrefilterManager', allow_none=True) | | 440 | + builtin_trap = Instance('IPython.core.builtin_trap.BuiltinTrap', allow_none=True) | | 441 | + display_trap = Instance('IPython.core.display_trap.DisplayTrap', allow_none=True) | | 442 | + extension_manager = Instance('IPython.core.extensions.ExtensionManager', allow_none=True) | | 443 | + payload_manager = Instance('IPython.core.payload.PayloadManager', allow_none=True) | | 444 | + history_manager = Instance('IPython.core.history.HistoryAccessorBase', allow_none=True) | | 445 | + magics_manager = Instance('IPython.core.magic.MagicsManager', allow_none=True) | | 446 | + | | 447 | + profile_dir = Instance('IPython.core.application.ProfileDir', allow_none=True) | 448 | 448 | @property | 449 | 449 | def profile(self): | 450 | 450 | if self.profile_dir is not None: | @@ -453,7 +453,7 @@ def profile(self): | 453 | 453 |
| 454 | 454 |
| 455 | 455 | # Private interface | 456 | | - _post_execute = Instance(dict) | | 456 | + _post_execute = Instance(dict, allow_none=True) | 457 | 457 |
| 458 | 458 | # Tracks any GUI loop loaded for pylab | 459 | 459 | pylab_gui_select = None | |
Collapse file Copy file name to clipboardExpand all lines: IPython/core/magic.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -301,7 +301,7 @@ class MagicsManager(Configurable): | 301 | 301 | # A registry of the original objects that we've been given holding magics. | 302 | 302 | registry = Dict | 303 | 303 |
| 304 | | - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC') | | 304 | + shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', allow_none=True) | 305 | 305 |
| 306 | 306 | auto_magic = Bool(True, config=True, help= | 307 | 307 | "Automatically call line magics without requiring explicit % prefix") | @@ -313,7 +313,7 @@ def _auto_magic_changed(self, name, value): | 313 | 313 | 'Automagic is OFF, % prefix IS needed for line magics.', | 314 | 314 | 'Automagic is ON, % prefix IS NOT needed for line magics.'] | 315 | 315 |
| 316 | | - user_magics = Instance('IPython.core.magics.UserMagics') | | 316 | + user_magics = Instance('IPython.core.magics.UserMagics', allow_none=True) | 317 | 317 |
| 318 | 318 | def __init__(self, shell=None, config=None, user_magics=None, **traits): | 319 | 319 |
| |
|