Skip to content

Commit a7e93c1

Browse files
authored
DOC Fix sphinx warnings and turn warnings into errors (#1247)
1 parent 0f89dfa commit a7e93c1

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33

44
# You can set these variables from the command line.
5-
SPHINXOPTS =
5+
SPHINXOPTS = -W # converts warnings into error
66
SPHINXBUILD = sphinx-build
77
SPHINXPROJ = torchaudio
88
SOURCEDIR = source

docs/source/backend.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,20 @@ You can switch from another backend to the ``"soundfile"`` backend with the foll
157157
If you are switching from `"soundfile" (legacy interface) <soundfile_legacy_backend>` backend, set ``torchaudio.USE_SOUNDFILE_LEGACY_INTERFACE`` flag **before** switching the backend.
158158

159159
info
160-
^^^^
160+
----
161161

162162
.. autofunction:: torchaudio.backend._soundfile_backend.info
163163

164164
load
165-
^^^^
165+
----
166166

167167
.. autofunction:: torchaudio.backend._soundfile_backend.load
168168

169169
.. autofunction:: torchaudio.backend._soundfile_backend.load_wav
170170

171171

172172
save
173-
^^^^
173+
----
174174

175175
.. autofunction:: torchaudio.backend._soundfile_backend.save
176176

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
'''
5959

6060
napoleon_use_ivar = True
61+
napoleon_numpy_docstring = False
62+
napoleon_google_docstring = True
6163

6264
# Add any paths that contain templates here, relative to this directory.
6365
templates_path = ['_templates']

torchaudio/_internal/module_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ def deprecated(direction: str, version: Optional[str] = None):
4444
direction: Migration steps to be given to users.
4545
"""
4646
def decorator(func):
47+
4748
@wraps(func)
4849
def wrapped(*args, **kwargs):
4950
message = (

torchaudio/backend/common.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from typing import Any, Optional
2-
3-
from torchaudio._internal import module_utils as _mod_utils
2+
import warnings
43

54

65
class AudioMetaData:
@@ -31,7 +30,6 @@ def __init__(
3130
self.encoding = encoding
3231

3332

34-
@_mod_utils.deprecated('Please migrate to `AudioMetaData`.', '0.9.0')
3533
class SignalInfo:
3634
"""One of return types of ``torchaudio.info`` functions.
3735
@@ -51,13 +49,18 @@ def __init__(self,
5149
rate: Optional[float] = None,
5250
precision: Optional[int] = None,
5351
length: Optional[int] = None) -> None:
52+
message = (
53+
f'{self.__module__}.{self.__class__.__name__} has been deprecated '
54+
'and will be removed from 0.9.0 release. '
55+
'Please migrate to `AudioMetaData`.'
56+
)
57+
warnings.warn(message)
5458
self.channels = channels
5559
self.rate = rate
5660
self.precision = precision
5761
self.length = length
5862

5963

60-
@_mod_utils.deprecated('Please migrate to `AudioMetaData`.', '0.9.0')
6164
class EncodingInfo:
6265
"""One of return types of ``torchaudio.info`` functions.
6366
@@ -82,6 +85,12 @@ def __init__(self,
8285
reverse_nibbles: Any = None,
8386
reverse_bits: Any = None,
8487
opposite_endian: Optional[bool] = None) -> None:
88+
message = (
89+
f'{self.__module__}.{self.__class__.__name__} has been deprecated '
90+
'and will be removed from 0.9.0 release. '
91+
'Please migrate to `AudioMetaData`.'
92+
)
93+
warnings.warn(message)
8594
self.encoding = encoding
8695
self.bits_per_sample = bits_per_sample
8796
self.compression = compression

torchaudio/backend/sox_io_backend.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,22 @@ def info(
2222
filepath (path-like object or file-like object):
2323
Source of audio data. When the function is not compiled by TorchScript,
2424
(e.g. ``torch.jit.script``), the following types are accepted;
25+
2526
* ``path-like``: file path
2627
* ``file-like``: Object with ``read(size: int) -> bytes`` method,
2728
which returns byte string of at most ``size`` length.
29+
2830
When the function is compiled by TorchScript, only ``str`` type is allowed.
2931
3032
Note:
33+
3134
* When the input type is file-like object, this function cannot
3235
get the correct length (``num_samples``) for certain formats,
3336
such as ``mp3`` and ``vorbis``.
3437
In this case, the value of ``num_samples`` is ``0``.
3538
* This argument is intentionally annotated as ``str`` only due to
3639
TorchScript compiler compatibility.
40+
3741
format (str, optional):
3842
Override the format detection with the given format.
3943
Providing the argument might help when libsox can not infer the format
@@ -103,14 +107,15 @@ def load(
103107
filepath (path-like object or file-like object):
104108
Source of audio data. When the function is not compiled by TorchScript,
105109
(e.g. ``torch.jit.script``), the following types are accepted;
110+
106111
* ``path-like``: file path
107112
* ``file-like``: Object with ``read(size: int) -> bytes`` method,
108113
which returns byte string of at most ``size`` length.
114+
109115
When the function is compiled by TorchScript, only ``str`` type is allowed.
110116
111-
Note:
112-
* This argument is intentionally annotated as ``str`` only due to
113-
TorchScript compiler compatibility.
117+
Note: This argument is intentionally annotated as ``str`` only due to
118+
TorchScript compiler compatibility.
114119
frame_offset (int):
115120
Number of frames to skip before start reading data.
116121
num_frames (int):

torchaudio/sox_effects/sox_effects.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,14 +173,16 @@ def apply_effects_file(
173173
Args:
174174
path (path-like object or file-like object):
175175
Source of audio data. When the function is not compiled by TorchScript,
176-
(e.g. ``torch.jit.script``), the following types are accepted;
176+
(e.g. ``torch.jit.script``), the following types are accepted:
177+
177178
* ``path-like``: file path
178179
* ``file-like``: Object with ``read(size: int) -> bytes`` method,
179180
which returns byte string of at most ``size`` length.
181+
180182
When the function is compiled by TorchScript, only ``str`` type is allowed.
181-
Note:
182-
* This argument is intentionally annotated as ``str`` only for
183-
TorchScript compiler compatibility.
183+
184+
Note: This argument is intentionally annotated as ``str`` only for
185+
TorchScript compiler compatibility.
184186
effects (List[List[str]]): List of effects.
185187
normalize (bool):
186188
When ``True``, this function always return ``float32``, and sample values are

0 commit comments

Comments
 (0)