Skip to content

Commit

Permalink
[Typing][B-98] Add type annotations for `python/paddle/distributed/en…
Browse files Browse the repository at this point in the history
…try_attr.py` (PaddlePaddle#66394)
  • Loading branch information
enkilee authored and Dale1314 committed Jul 28, 2024
1 parent 65cbada commit 16fb00c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions python/paddle/distributed/entry_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations

__all__ = []

Expand Down Expand Up @@ -45,10 +46,10 @@ class EntryAttr:
"""

def __init__(self):
def __init__(self) -> None:
self._name = None

def _to_attr(self):
def _to_attr(self) -> str:
"""
Returns the attributes of this parameter.
Expand Down Expand Up @@ -87,7 +88,7 @@ class ProbabilityEntry(EntryAttr):
"""

def __init__(self, probability):
def __init__(self, probability: float) -> None:
super().__init__()

if not isinstance(probability, float):
Expand All @@ -99,7 +100,7 @@ def __init__(self, probability):
self._name = "probability_entry"
self._probability = probability

def _to_attr(self):
def _to_attr(self) -> str:
return ":".join([self._name, str(self._probability)])


Expand Down Expand Up @@ -131,7 +132,7 @@ class CountFilterEntry(EntryAttr):
"""

def __init__(self, count_filter):
def __init__(self, count_filter: int) -> None:
super().__init__()

if not isinstance(count_filter, int):
Expand All @@ -147,7 +148,7 @@ def __init__(self, count_filter):
self._name = "count_filter_entry"
self._count_filter = count_filter

def _to_attr(self):
def _to_attr(self) -> str:
return ":".join([self._name, str(self._count_filter)])


Expand Down Expand Up @@ -182,7 +183,7 @@ class ShowClickEntry(EntryAttr):
"""

def __init__(self, show_name, click_name):
def __init__(self, show_name: str, click_name: str) -> None:
super().__init__()

if not isinstance(show_name, str) or not isinstance(click_name, str):
Expand All @@ -192,5 +193,5 @@ def __init__(self, show_name, click_name):
self._show_name = show_name
self._click_name = click_name

def _to_attr(self):
def _to_attr(self) -> str:
return ":".join([self._name, self._show_name, self._click_name])

0 comments on commit 16fb00c

Please sign in to comment.