Skip to content

Commit 4aea048

Browse files
committed
docs: error: improve docstings, specify attribute types
1 parent 34c0e3a commit 4aea048

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

stagpy/error.py

Lines changed: 20 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ class NoSnapshotError(StagpyError):
2727
"""Raised when no snapshot can be found.
2828
2929
Attributes:
30-
sdat: the :class:`~stagpy.stagyydata.StagyyData` instance for which no
31-
snapshot was found.
30+
sdat (StagyyData): the `StagyyData` for which no snapshot was found.
3231
"""
3332

3433
def __init__(self, sdat: StagyyData):
@@ -40,8 +39,7 @@ class NoGeomError(StagpyError):
4039
"""Raised when no geometry info can be found.
4140
4241
Attributes:
43-
step: the :class:`~stagpy._step.Step` instance for which no geometry
44-
was found.
42+
step (Step): the `Step` for which no geometry was found.
4543
"""
4644

4745
def __init__(self, step: Step):
@@ -53,8 +51,7 @@ class NoTimeError(StagpyError):
5351
"""Raised when no time can be found for a step.
5452
5553
Attributes:
56-
step: the :class:`~stagpy._step.Step` instance for which no geometry
57-
was found.
54+
step (Step): the `Step` instance for which no geometry was found.
5855
"""
5956

6057
def __init__(self, step: Step):
@@ -66,8 +63,7 @@ class NoRefstateError(StagpyError):
6663
"""Raised when no refstate output can be found.
6764
6865
Attributes:
69-
sdat: the :class:`~stagpy.stagyydata.StagyyData` instance for which no
70-
refstate output was found.
66+
sdat (StagyyData): the `StagyyData` instance for which no refstate was found.
7167
"""
7268

7369
def __init__(self, sdat: StagyyData):
@@ -79,7 +75,7 @@ class NoParFileError(StagpyError):
7975
"""Raised when no par file can be found.
8076
8177
Attributes:
82-
parfile: the expected path of the par file.
78+
parfile (PathLike): the expected path of the par file.
8379
"""
8480

8581
def __init__(self, parfile: PathLike):
@@ -97,8 +93,8 @@ class ParsingError(StagpyError):
9793
"""Raised when a parsing error occurs.
9894
9995
Attributes:
100-
file: path of the file where a parsing problem was encountered.
101-
msg: error message.
96+
file (PathLike): path of the file where a parsing problem was encountered.
97+
msg (str): error message.
10298
"""
10399

104100
def __init__(self, file: PathLike, msg: str):
@@ -111,10 +107,9 @@ class InvalidTimestepError(StagpyError, KeyError):
111107
"""Raised when invalid time step is requested.
112108
113109
Attributes:
114-
sdat: the :class:`~stagpy.stagyydata.StagyyData` instance to which the
115-
request was made.
116-
istep: the invalid time step index.
117-
msg: the error message.
110+
sdat (StagyyData): the `StagyyData` instance to which the request was made.
111+
istep (int): the invalid time step index.
112+
msg (str): the error message.
118113
"""
119114

120115
def __init__(self, sdat: StagyyData, istep: int, msg: str):
@@ -128,10 +123,9 @@ class InvalidSnapshotError(StagpyError, KeyError):
128123
"""Raised when invalid snapshot is requested.
129124
130125
Attributes:
131-
sdat: the :class:`~stagpy.stagyydata.StagyyData` instance to which the
132-
request was made.
133-
isnap: the invalid snapshot index.
134-
msg: the error message.
126+
sdat (StagyyData): the `StagyyData` instance to which the request was made.
127+
isnap (int): the invalid snapshot index.
128+
msg (str): the error message.
135129
"""
136130

137131
def __init__(self, sdat: StagyyData, isnap: int, msg: str):
@@ -145,7 +139,7 @@ class InvalidTimeFractionError(StagpyError):
145139
"""Raised when invalid fraction of series is requested.
146140
147141
Attributes:
148-
fraction: the invalid fraction.
142+
fraction (float): the invalid fraction.
149143
"""
150144

151145
def __init__(self, fraction: float):
@@ -157,7 +151,7 @@ class InvalidNfieldsError(StagpyError):
157151
"""Raised when invalid nfields_max is requested.
158152
159153
Attributes:
160-
nfields: the invalid number of field.
154+
nfields (int): the invalid number of field.
161155
"""
162156

163157
def __init__(self, nfields: int):
@@ -169,7 +163,7 @@ class InvalidZoomError(StagpyError):
169163
"""Raised when invalid zoom is requested.
170164
171165
Attributes:
172-
zoom: the invalid zoom level.
166+
zoom (float): the invalid zoom level.
173167
"""
174168

175169
def __init__(self, zoom: float):
@@ -187,7 +181,7 @@ class UnknownVarError(StagpyError, KeyError):
187181
"""Raised when invalid var is requested.
188182
189183
Attributes:
190-
varname: the invalid var name.
184+
varname (str): the invalid var name.
191185
"""
192186

193187
def __init__(self, varname: str):
@@ -196,27 +190,18 @@ def __init__(self, varname: str):
196190

197191

198192
class UnknownFieldVarError(UnknownVarError):
199-
"""Raised when invalid field var is requested.
200-
201-
Derived from :class:`~stagpy.error.UnknownVarError`.
202-
"""
193+
"""Raised when invalid field var is requested."""
203194

204195
pass
205196

206197

207198
class UnknownRprofVarError(UnknownVarError):
208-
"""Raised when invalid rprof var is requested.
209-
210-
Derived from :class:`~stagpy.error.UnknownVarError`.
211-
"""
199+
"""Raised when invalid rprof var is requested."""
212200

213201
pass
214202

215203

216204
class UnknownTimeVarError(UnknownVarError):
217-
"""Raised when invalid time var is requested.
218-
219-
Derived from :class:`~stagpy.error.UnknownVarError`.
220-
"""
205+
"""Raised when invalid time var is requested."""
221206

222207
pass

0 commit comments

Comments
 (0)