Skip to content

Commit 68aca88

Browse files
Will Barrettmistercrunch
Will Barrett
authored andcommitted
Re-enable pylint on some configuration files (#8767)
* re-enable pylint for superset/config.py * re-enable pylint on superset/migrations/env.py * re-enable pylint for superset/legacy.py * re-enable pylint for superset/forms.py * re-enable pylint for superset/stats_logger.py * Tweaks to make mypy and pylint happy * black
1 parent 7dba3f5 commit 68aca88

File tree

5 files changed

+33
-31
lines changed

5 files changed

+33
-31
lines changed

superset/config.py

+21-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=C,R,W
1817
"""The main config file for Superset
1918
2019
All configuration in this file can be overridden by providing a superset_config
@@ -63,23 +62,24 @@ def _try_json_readversion(filepath):
6362
try:
6463
with open(filepath, "r") as f:
6564
return json.load(f).get("version")
66-
except Exception:
65+
except Exception: # pylint: disable=broad-except
6766
return None
6867

6968

70-
def _try_json_readsha(filepath, length):
69+
def _try_json_readsha(filepath, length): # pylint: disable=unused-argument
7170
try:
7271
with open(filepath, "r") as f:
73-
return json.load(f).get("GIT_SHA")[:length]
74-
except Exception:
72+
return json.load(f).get("GIT_SHA")
73+
except Exception: # pylint: disable=broad-except
7574
return None
7675

7776

78-
# Depending on the context in which this config is loaded, the version_info.json file
79-
# may or may not be available, as it is generated on install via setup.py. In the event
80-
# that we're actually running Superset, we will have already installed, therefore it WILL
81-
# exist. When unit tests are running, however, it WILL NOT exist, so we fall
82-
# back to reading package.json
77+
# Depending on the context in which this config is loaded, the
78+
# version_info.json file may or may not be available, as it is
79+
# generated on install via setup.py. In the event that we're
80+
# actually running Superset, we will have already installed,
81+
# therefore it WILL exist. When unit tests are running, however,
82+
# it WILL NOT exist, so we fall back to reading package.json
8383
VERSION_STRING = _try_json_readversion(VERSION_INFO_FILE) or _try_json_readversion(
8484
PACKAGE_JSON_FILE
8585
)
@@ -110,7 +110,9 @@ def _try_json_readsha(filepath, length):
110110
# ---------------------------------------------------------
111111

112112
# Your App secret key
113-
SECRET_KEY = "\2\1thisismyscretkey\1\2\e\y\y\h"
113+
SECRET_KEY = (
114+
"\2\1thisismyscretkey\1\2\e\y\y\h" # pylint: disable=anomalous-backslash-in-string
115+
)
114116

115117
# The SQLAlchemy connection string.
116118
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(DATA_DIR, "superset.db")
@@ -436,7 +438,7 @@ def _try_json_readsha(filepath, length):
436438
# http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html
437439

438440

439-
class CeleryConfig(object):
441+
class CeleryConfig(object): # pylint: disable=too-few-public-methods
440442
BROKER_URL = "sqla+sqlite:///celerydb.sqlite"
441443
CELERY_IMPORTS = ("superset.sql_lab", "superset.tasks")
442444
CELERY_RESULT_BACKEND = "db+sqlite:///celery_results.sqlite"
@@ -460,7 +462,7 @@ class CeleryConfig(object):
460462
}
461463

462464

463-
CELERY_CONFIG = CeleryConfig
465+
CELERY_CONFIG = CeleryConfig # pylint: disable=invalid-name
464466

465467
# Set celery config to None to disable all the above configuration
466468
# CELERY_CONFIG = None
@@ -728,7 +730,11 @@ class CeleryConfig(object):
728730
SIP_15_ENABLED = False
729731
SIP_15_GRACE_PERIOD_END: Optional[date] = None # exclusive
730732
SIP_15_DEFAULT_TIME_RANGE_ENDPOINTS = ["unknown", "inclusive"]
731-
SIP_15_TOAST_MESSAGE = 'Action Required: Preview then save your chart using the new time range endpoints <a target="_blank" href="{url}" class="alert-link">here</a>.'
733+
SIP_15_TOAST_MESSAGE = (
734+
"Action Required: Preview then save your chart using the"
735+
'new time range endpoints <a target="_blank" href="{url}"'
736+
'class="alert-link">here</a>.'
737+
)
732738

733739
if CONFIG_PATH_ENV_VAR in os.environ:
734740
# Explicitly import config module that is not necessarily in pythonpath; useful
@@ -749,7 +755,7 @@ class CeleryConfig(object):
749755
raise
750756
elif importlib.util.find_spec("superset_config"):
751757
try:
752-
from superset_config import * # pylint: disable=import-error
758+
from superset_config import * # pylint: disable=import-error,wildcard-import,unused-wildcard-import
753759
import superset_config # pylint: disable=import-error
754760

755761
print(f"Loaded your LOCAL configuration at [{superset_config.__file__}]")

superset/forms.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,22 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=C,R,W
1817
"""Contains the logic to create cohesive forms on the explore view"""
18+
from typing import List # pylint: disable=unused-import
19+
1920
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
2021
from wtforms import Field
2122

2223

2324
class CommaSeparatedListField(Field):
2425
widget = BS3TextFieldWidget()
26+
data = [] # type: List[str]
2527

2628
def _value(self):
2729
if self.data:
2830
return u", ".join(self.data)
29-
else:
30-
return u""
31+
32+
return u""
3133

3234
def process_formdata(self, valuelist):
3335
if valuelist:

superset/legacy.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=C,R,W
1817
"""Code related with dealing with legacy / change management"""
1918

2019

superset/migrations/env.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=C,R,W
1817
import logging
1918
from logging.config import fileConfig
2019

@@ -72,7 +71,9 @@ def run_migrations_online():
7271
# this callback is used to prevent an auto-migration from being generated
7372
# when there are no changes to the schema
7473
# reference: https://alembic.sqlalchemy.org/en/latest/cookbook.html
75-
def process_revision_directives(context, revision, directives):
74+
def process_revision_directives(
75+
context, revision, directives
76+
): # pylint: disable=redefined-outer-name, unused-argument
7677
if getattr(config.cmd_opts, "autogenerate", False):
7778
script = directives[0]
7879
if script.upgrade_ops.is_empty():

superset/stats_logger.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
# pylint: disable=C,R,W
1817
import logging
1918

2019
from colorama import Fore, Style
@@ -59,22 +58,17 @@ def timing(self, key, value):
5958
(Fore.CYAN + f"[stats_logger] (timing) {key} | {value} " + Style.RESET_ALL)
6059
)
6160

62-
def gauge(self, key, value):
61+
def gauge(self, key):
6362
logging.debug(
64-
(
65-
Fore.CYAN
66-
+ "[stats_logger] (gauge) "
67-
+ f"{key} | {value}"
68-
+ Style.RESET_ALL
69-
)
63+
(Fore.CYAN + "[stats_logger] (gauge) " + f"{key}" + Style.RESET_ALL)
7064
)
7165

7266

7367
try:
7468
from statsd import StatsClient
7569

7670
class StatsdStatsLogger(BaseStatsLogger):
77-
def __init__(
71+
def __init__( # pylint: disable=super-init-not-called
7872
self, host="localhost", port=8125, prefix="superset", statsd_client=None
7973
):
8074
"""
@@ -102,5 +96,5 @@ def gauge(self, key):
10296
self.client.gauge(key)
10397

10498

105-
except Exception:
99+
except Exception: # pylint: disable=broad-except
106100
pass

0 commit comments

Comments
 (0)