Skip to content

Commit

Permalink
add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsailer committed Mar 24, 2022
1 parent c45ee44 commit 2e39b36
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions jupyter_server/services/sessions/sessionmanager.py
Expand Up @@ -28,16 +28,16 @@


class KernelSessionRecordConflict(Exception):
"""An exception raised when"""

pass


@dataclass
class KernelSessionRecord:
"""A record object for tracking a Jupyter Server Kernel Session.
Two records are equal if they share the
Two records that share a session_id must also share a kernel_id, while
kernels can have multiple session (and thereby) session_ids
associated with them.
"""

session_id: Union[None, str] = None
Expand Down Expand Up @@ -89,11 +89,12 @@ def update(self, other: "KernelSessionRecord") -> None:


class KernelSessionRecordList:
"""Handy object for storing and managing a list of KernelSessionRecords.
"""An object for storing and managing a list of KernelSessionRecords.

This comment has been minimized.

Copy link
@blink1073

blink1073 Mar 24, 2022

Collaborator

Not so handy it seems. 😄

This comment has been minimized.

Copy link
@Zsailer

Zsailer Mar 24, 2022

Author Member

😆 I thought someone might make fun of me for using such conversational language.

When adding a record to the list, first checks if the record
already exists. If it does, the record will be updated with
the new information.
When adding a record to the list, the KernelSessionRecordList
first checks if the record already exists in the list. If it does,
the record will be updated with the new information; otherwise,
it will be appended.
"""

def __init__(self, *records):
Expand All @@ -119,6 +120,9 @@ def __len__(self):
return len(self._records)

def get(self, record: Union[KernelSessionRecord, str]) -> KernelSessionRecord:
"""Return a full KernelSessionRecord from a session_id, kernel_id, or
incomplete KernelSessionRecord.
"""
if isinstance(record, str):
for r in self._records:
if record == r.kernel_id or record == r.session_id:
Expand Down

0 comments on commit 2e39b36

Please sign in to comment.