Skip to content

Commit

Permalink
Pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vshampor committed Aug 7, 2023
1 parent 9c4ab19 commit 6acb790
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 29 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ disable = arguments-differ,
duplicate-code,
consider-using-f-string,
logging-fstring-interpolation,
cyclic-import
cyclic-import,
useless-import-alias

max-line-length = 120
ignore-docstrings = yes
Expand Down
2 changes: 1 addition & 1 deletion nncf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

_SUPPORTED_FRAMEWORKS = ["torch", "tensorflow", "onnx", "openvino"]


#pylint:disable=wrong-import-position
from importlib.util import find_spec as _find_spec # noqa: E402

_AVAILABLE_FRAMEWORKS = {name: _find_spec(name) is not None for name in _SUPPORTED_FRAMEWORKS}
Expand Down
2 changes: 1 addition & 1 deletion nncf/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class NNCFConfig(dict):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__nncf_extra_structs: dict[str, NNCFExtraConfigStruct] = {}
self.__nncf_extra_structs: Dict[str, NNCFExtraConfigStruct] = {}

@classmethod
def from_dict(cls, nncf_dict: Dict) -> "NNCFConfig":
Expand Down
1 change: 1 addition & 0 deletions nncf/tensorflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""
Base subpackage for NNCF TensorFlow functionality.
"""
# pylint:skip-file
import tensorflow
from packaging import version

Expand Down
2 changes: 0 additions & 2 deletions nncf/torch/dynamic_graph/graph_tracer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ def trace_graph(
) -> DynamicGraph:
sd = deepcopy(model.state_dict())

from nncf.torch.dynamic_graph.context import TracingContext # pylint: disable=cyclic-import

if context_to_use is None:
context_to_use = TracingContext()

Expand Down
2 changes: 1 addition & 1 deletion nncf/torch/graph/graph_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def __init__(self, custom_forward_fn: Callable[[torch.nn.Module], Any]):
def build_graph(
self,
model: torch.nn.Module,
context_to_use: Optional["TracingContext"] = None,
context_to_use: Optional[TracingContext] = None,
as_eval: bool = False,
input_infos: List[ModelInputInfo] = None,
) -> PTNNCFGraph:
Expand Down
18 changes: 9 additions & 9 deletions nncf/torch/quantization/base_ctrl.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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 nncf.torch.compression_method_api import PTCompressionAlgorithmController


Expand Down
18 changes: 9 additions & 9 deletions nncf/torch/quantization/precision_init/definitions.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# Copyright (c) 2023 Intel Corporation
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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.
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# 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 typing import List

from nncf.common.quantization.structs import QuantizerConfig
Expand Down
2 changes: 2 additions & 0 deletions nncf/torch/quantization/precision_init/hawq_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from nncf.torch.quantization.adjust_padding import add_adjust_padding_nodes
from nncf.torch.quantization.layers import QUANTIZATION_MODULES
from nncf.torch.quantization.precision_init.adjacent_quantizers import GroupsOfAdjacentQuantizers

# pylint:disable=unused-import
from nncf.torch.quantization.precision_init.definitions import QConfigSequenceForHAWQToEvaluate
from nncf.torch.quantization.precision_init.perturbations import PerturbationObserver
from nncf.torch.quantization.precision_init.perturbations import Perturbations
Expand Down
3 changes: 1 addition & 2 deletions nncf/torch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from nncf.common.logging import nncf_logger
from nncf.common.scopes import matches_any
from nncf.torch.dynamic_graph.scope import Scope
from nncf.torch.dynamic_graph.scope import ScopeElement
from nncf.torch.dynamic_graph.trace_tensor import TracedTensor
from nncf.torch.layer_utils import _NNCFModuleMixin
from nncf.torch.structures import ExecutionParameters
Expand Down Expand Up @@ -55,8 +56,6 @@ def get_all_modules_by_type(
if isinstance(module_types, str):
module_types = [module_types]
found = OrderedDict()
from nncf.torch.dynamic_graph.scope import Scope # pylint: disable=cyclic-import
from nncf.torch.dynamic_graph.scope import ScopeElement # pylint: disable=cyclic-import

if current_scope is None:
current_scope = Scope()
Expand Down
1 change: 1 addition & 0 deletions tests/common/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#pylint:disable=unused-import
from tests.shared.logging import nncf_caplog # noqa: F401
6 changes: 3 additions & 3 deletions tests/torch/quantization/test_logarithm_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def __len__(self):
data_loader = torch.utils.data.DataLoader(RandDatasetMock(), batch_size=1, shuffle=False, drop_last=True)

class SquadInitializingDataloader(nncf.torch.initialization.PTInitializingDataLoader):
def get_inputs(self, batch):
return batch, {}
def get_inputs(self, dataloader_output):
return dataloader_output, {}

def get_target(self, batch):
def get_target(self, dataloader_output):
return None

initializing_data_loader = SquadInitializingDataloader(data_loader)
Expand Down

0 comments on commit 6acb790

Please sign in to comment.