Skip to content

Commit

Permalink
[CodeStyle][Ruff][BUAA][C-[11-20]] Fix Ruff RSE102 diagnostic for 1…
Browse files Browse the repository at this point in the history
…0 files in `python/paddle/` (#67124)
  • Loading branch information
Jeff114514 authored Aug 7, 2024
1 parent 296df15 commit df2527c
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,13 @@ def rollback(self, version: int):
self.records[:] = self.records[:version]

def get(self, key):
raise NotImplementedError()
raise NotImplementedError

def set(self, key, value):
raise NotImplementedError()
raise NotImplementedError

def apply(self, mutation: Mutation, write_cache: InnerMutableDataT):
raise NotImplementedError()
raise NotImplementedError

def reproduce(self, version: int | None = None) -> InnerMutableDataT:
if version is None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def _break_graph_when_if(self, result, instr: Instruction):
NotImplementedError: If the method is not implemented.
"""
raise NotImplementedError()
raise NotImplementedError

def transform(self):
"""
Expand All @@ -416,7 +416,7 @@ def transform(self):
NotImplementedError: If the method is not implemented.
"""
raise NotImplementedError()
raise NotImplementedError

def find_space_of_var_name(self, name):
code = self._graph.pycode_gen._origin_code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ def restore_state(self, state: SideEffectsState):

class SideEffectRestorer:
def pre_gen(self, codegen: PyCodeGen):
raise NotImplementedError()
raise NotImplementedError

def post_gen(self, codegen: PyCodeGen):
raise NotImplementedError()
raise NotImplementedError


class DictSideEffectRestorer(SideEffectRestorer):
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/jit/sot/opcode_translator/executor/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def gen_instructions(self, codegen: PyCodeGen) -> None:
Args:
codegen (PyCodeGen): An instance of PyCodeGen to generate instructions.
"""
raise NotImplementedError()
raise NotImplementedError

# TODO(xiongkun): trace_value_from_frame is not a good name, it should be more related to guard but not tracable.
def trace_value_from_frame(self) -> StringifiedExpression:
Expand All @@ -67,7 +67,7 @@ def trace_value_from_frame(self) -> StringifiedExpression:
Returns:
The value of the tracked variables.
"""
raise NotImplementedError()
raise NotImplementedError

def is_traceable(self) -> bool:
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def get_py_value(self, allow_tensor=False) -> Any:
"""
Abstract method to get the value of the variable
"""
raise NotImplementedError()
raise NotImplementedError

def get_py_type(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def next(self):
self.idx += 1
return val
else:
raise StopIteration()
raise StopIteration

def to_list(self) -> list:
if self.has_side_effect():
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/jit/sot/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,10 +272,10 @@ def clear(self):
self.hit_num = 0

def key_fn(self, *args, **kwargs):
raise NotImplementedError()
raise NotImplementedError

def value_fn(self, *args, **kwargs):
raise NotImplementedError()
raise NotImplementedError


def execute_time(func):
Expand Down
10 changes: 5 additions & 5 deletions python/paddle/nn/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ def _squared_l2_norm(x):

class BaseErrorClipAttr:
def __str__(self):
raise NotImplementedError()
raise NotImplementedError

def _append_clip_op(self, block, grad_name):
raise NotImplementedError()
raise NotImplementedError


class ErrorClipByValue(BaseErrorClipAttr):
Expand Down Expand Up @@ -353,7 +353,7 @@ def __init__(self):
super().__init__()

def __str__(self):
raise NotImplementedError()
raise NotImplementedError

@imperative_base.no_grad()
def _dygraph_clip(self, params_grads):
Expand Down Expand Up @@ -384,10 +384,10 @@ def __call__(
return self._static_clip(params_grads)

def _process_context(self, context, param, grad):
raise NotImplementedError()
raise NotImplementedError

def _create_operators(self, param, grad):
raise NotImplementedError()
raise NotImplementedError


class ClipGradByValue(ClipGradBase):
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/nn/initializer/initializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def forward(
self, param: paddle.Tensor, block: paddle.pir.Block | None = None
) -> paddle.Tensor | None:
"""Add corresponding initialization operations to the network."""
raise NotImplementedError()
raise NotImplementedError

def _lazy_init(
self, param: paddle.Tensor, block: paddle.pir.Block | None = None
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/regularizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def __call__(
self, param: paddle.Tensor, grad: paddle.Tensor, block: pir.Block
):
"""Add corresponding weight decay operations to the network"""
raise NotImplementedError()
raise NotImplementedError

def __str__(self):
"""Debug string"""
raise NotImplementedError()
raise NotImplementedError


class L1Decay(WeightDecayRegularizer):
Expand Down

0 comments on commit df2527c

Please sign in to comment.