Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prohibit wildcard import in pylint #8893

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ disable=raw-checker-failed,
raise-missing-from,
raising-format-tuple,
wrong-exception-operation,
wildcard-import,
deprecated-module,
import-self,
preferred-module,
Expand Down Expand Up @@ -516,7 +515,8 @@ enable=singleton-comparison,
logging-unsupported-format,
logging-format-truncated,
logging-too-many-args,
logging-too-few-args
logging-too-few-args,
wildcard-import


[BASIC]
Expand Down
3 changes: 2 additions & 1 deletion cvat-sdk/cvat_sdk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#
# SPDX-License-Identifier: MIT

from cvat_sdk.api_client.models import * # pylint: disable=unused-import,redefined-builtin
# Reexport symbols for public SDK API
from cvat_sdk.api_client.models import * # pylint: disable=wildcard-import
6 changes: 3 additions & 3 deletions cvat/apps/engine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (C) 2018-2022 Intel Corporation
# Copyright (C) 2022 CVAT.ai Corporation
# Copyright (C) 2022-2024 CVAT.ai Corporation
#
# SPDX-License-Identifier: MIT


from .schema import * # force import of declared symbols
# Force execution of declared symbols
from .schema import * # pylint: disable=wildcard-import
3 changes: 2 additions & 1 deletion cvat/settings/development.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: MIT

from .base import *
# Inherit parent config
from .base import * # pylint: disable=wildcard-import

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
Expand Down
3 changes: 2 additions & 1 deletion cvat/settings/email_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#
# SPDX-License-Identifier: MIT

from cvat.settings.production import *
# Inherit parent config
from cvat.settings.production import * # pylint: disable=wildcard-import

# https://github.com/pennersr/django-allauth
ACCOUNT_AUTHENTICATION_METHOD = 'username_email'
Expand Down
3 changes: 2 additions & 1 deletion cvat/settings/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: MIT

from .base import *
# Inherit parent config
from .base import * # pylint: disable=wildcard-import

DEBUG = False

Expand Down
3 changes: 2 additions & 1 deletion cvat/settings/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

import tempfile

from .development import *
# Inherit parent config
from .development import * # pylint: disable=wildcard-import

DATABASES = {
'default': {
Expand Down
3 changes: 2 additions & 1 deletion cvat/settings/testing_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#
# SPDX-License-Identifier: MIT

from cvat.settings.production import *
# Inherit parent config
from cvat.settings.production import * # pylint: disable=wildcard-import

# We use MD5 password hasher instead of default PBKDF2 here to speed up REST API tests,
# because the current implementation of the tests requires authentication in each test case
Expand Down
18 changes: 10 additions & 8 deletions serverless/pytorch/foolwood/siammask/nuclio/model_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,29 @@
#
# SPDX-License-Identifier: MIT

from tools.test import *
import os
from copy import copy

import jsonpickle
import numpy as np
import tools.test as impl


class ModelHandler:
def __init__(self):
# Setup device
self.device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
torch.backends.cudnn.benchmark = True
self.device = impl.torch.device('cuda' if impl.torch.cuda.is_available() else 'cpu')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

torch is just PyTorch, so could you import it normally (import torch)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change any logic in this script.

impl.torch.backends.cudnn.benchmark = True

base_dir = os.path.abspath(os.environ.get("MODEL_PATH",
"/opt/nuclio/SiamMask/experiments/siammask_sharp"))
class configPath:
config = os.path.join(base_dir, "config_davis.json")

self.config = load_config(configPath)
self.config = impl.load_config(configPath)
from custom import Custom
siammask = Custom(anchors=self.config['anchors'])
self.siammask = load_pretrain(siammask, os.path.join(base_dir, "SiamMask_DAVIS.pth"))
self.siammask = impl.load_pretrain(siammask, os.path.join(base_dir, "SiamMask_DAVIS.pth"))
self.siammask.eval().to(self.device)

def encode_state(self, state):
Expand All @@ -37,7 +39,7 @@ def encode_state(self, state):

def decode_state(self, state):
for k,v in state.items():
state[k] = jsonpickle.decode(v)
state[k] = jsonpickle.decode(v) # nosec: B301

state['net'] = copy(self.siammask)
state['net'].zf = state['net.zf']
Expand All @@ -52,12 +54,12 @@ def infer(self, image, shape, state):
target_pos = np.array([(xtl + xbr) / 2, (ytl + ybr) / 2])
target_sz = np.array([xbr - xtl, ybr - ytl])
siammask = copy(self.siammask) # don't modify self.siammask
state = siamese_init(image, target_pos, target_sz, siammask,
state = impl.siamese_init(image, target_pos, target_sz, siammask,
self.config['hp'], device=self.device)
state = self.encode_state(state)
else: # track
state = self.decode_state(state)
state = siamese_track(state, image, mask_enable=True,
state = impl.siamese_track(state, image, mask_enable=True,
refine_enable=True, device=self.device)
shape = state['ploygon'].flatten().tolist()
state = self.encode_state(state)
Expand Down
3 changes: 2 additions & 1 deletion tests/python/cli/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#
# SPDX-License-Identifier: MIT

from sdk.fixtures import * # pylint: disable=unused-import
# Force execution of fixture definitions
from sdk.fixtures import * # pylint: disable=wildcard-import
7 changes: 4 additions & 3 deletions tests/python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# SPDX-License-Identifier: MIT

from shared.fixtures.data import *
from shared.fixtures.init import *
from shared.fixtures.util import *
# Force execution of fixture definitions
from shared.fixtures.data import * # pylint: disable=wildcard-import
from shared.fixtures.init import * # pylint: disable=wildcard-import
from shared.fixtures.util import * # pylint: disable=wildcard-import
3 changes: 2 additions & 1 deletion tests/python/sdk/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
#
# SPDX-License-Identifier: MIT

from .fixtures import *
# Force execution of fixture definitions
from .fixtures import * # pylint: disable=wildcard-import
Loading