Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pylint fixes
Browse files Browse the repository at this point in the history
vshampor committed Aug 7, 2023
1 parent 9c4ab19 commit 189ac9e
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
@@ -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
2 changes: 1 addition & 1 deletion nncf/__init__.py
Original file line number Diff line number Diff line change
@@ -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}
2 changes: 1 addition & 1 deletion nncf/config/config.py
Original file line number Diff line number Diff line change
@@ -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":
1 change: 1 addition & 0 deletions nncf/tensorflow/__init__.py
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
"""
Base subpackage for NNCF TensorFlow functionality.
"""
# pylint:skip-file
import tensorflow
from packaging import version

2 changes: 0 additions & 2 deletions nncf/torch/dynamic_graph/graph_tracer.py
Original file line number Diff line number Diff line change
@@ -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()

2 changes: 1 addition & 1 deletion nncf/torch/graph/graph_builder.py
Original file line number Diff line number Diff line change
@@ -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:
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


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
2 changes: 2 additions & 0 deletions nncf/torch/quantization/precision_init/hawq_debug.py
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions nncf/torch/utils.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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()
1 change: 1 addition & 0 deletions tests/common/conftest.py
Original file line number Diff line number Diff line change
@@ -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
@@ -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)

0 comments on commit 189ac9e

Please sign in to comment.