diff --git a/jupyter_client/client.py b/jupyter_client/client.py index 8b568363..a52cecc7 100644 --- a/jupyter_client/client.py +++ b/jupyter_client/client.py @@ -117,8 +117,8 @@ def __del__(self): """Handle garbage collection. Destroy context if applicable.""" if ( self._created_context - and self.context is not None - and not self.context.closed # type:ignore[redundant-expr] + and self.context is not None # type:ignore[redundant-expr] + and not self.context.closed ): if self.channels_running: if self.log: diff --git a/jupyter_client/kernelspec.py b/jupyter_client/kernelspec.py index 38756590..3ba91367 100644 --- a/jupyter_client/kernelspec.py +++ b/jupyter_client/kernelspec.py @@ -242,8 +242,8 @@ def _get_kernel_spec_by_name(self, kernel_name, resource_dir): resource_dir=resource_dir, **get_kernel_dict() ) # type:ignore[operator] if not kspec: - kspec = self.kernel_spec_class.from_resource_dir( - resource_dir # type:ignore[attr-defined] + kspec = self.kernel_spec_class.from_resource_dir( # type:ignore[attr-defined] + resource_dir ) if not KPF.instance(parent=self.parent).is_provisioner_available(kspec):