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
This commit is contained in:
Will Barrett
2019-12-06 14:30:11 -08:00
committed by Maxime Beauchemin
parent 7dba3f54ee
commit 68aca88c54
5 changed files with 33 additions and 31 deletions

View File

@@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=C,R,W
"""The main config file for Superset
All configuration in this file can be overridden by providing a superset_config
@@ -63,23 +62,24 @@ def _try_json_readversion(filepath):
try:
with open(filepath, "r") as f:
return json.load(f).get("version")
except Exception:
except Exception: # pylint: disable=broad-except
return None
def _try_json_readsha(filepath, length):
def _try_json_readsha(filepath, length): # pylint: disable=unused-argument
try:
with open(filepath, "r") as f:
return json.load(f).get("GIT_SHA")[:length]
except Exception:
return json.load(f).get("GIT_SHA")
except Exception: # pylint: disable=broad-except
return None
# Depending on the context in which this config is loaded, the version_info.json file
# may or may not be available, as it is generated on install via setup.py. In the event
# that we're actually running Superset, we will have already installed, therefore it WILL
# exist. When unit tests are running, however, it WILL NOT exist, so we fall
# back to reading package.json
# Depending on the context in which this config is loaded, the
# version_info.json file may or may not be available, as it is
# generated on install via setup.py. In the event that we're
# actually running Superset, we will have already installed,
# therefore it WILL exist. When unit tests are running, however,
# it WILL NOT exist, so we fall back to reading package.json
VERSION_STRING = _try_json_readversion(VERSION_INFO_FILE) or _try_json_readversion(
PACKAGE_JSON_FILE
)
@@ -110,7 +110,9 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
# ---------------------------------------------------------
# Your App secret key
SECRET_KEY = "\2\1thisismyscretkey\1\2\e\y\y\h"
SECRET_KEY = (
"\2\1thisismyscretkey\1\2\e\y\y\h" # pylint: disable=anomalous-backslash-in-string
)
# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = "sqlite:///" + os.path.join(DATA_DIR, "superset.db")
@@ -436,7 +438,7 @@ WARNING_MSG = None
# http://docs.celeryproject.org/en/latest/getting-started/brokers/index.html
class CeleryConfig(object):
class CeleryConfig(object): # pylint: disable=too-few-public-methods
BROKER_URL = "sqla+sqlite:///celerydb.sqlite"
CELERY_IMPORTS = ("superset.sql_lab", "superset.tasks")
CELERY_RESULT_BACKEND = "db+sqlite:///celery_results.sqlite"
@@ -460,7 +462,7 @@ class CeleryConfig(object):
}
CELERY_CONFIG = CeleryConfig
CELERY_CONFIG = CeleryConfig # pylint: disable=invalid-name
# Set celery config to None to disable all the above configuration
# CELERY_CONFIG = None
@@ -728,7 +730,11 @@ SQLALCHEMY_EXAMPLES_URI = None
SIP_15_ENABLED = False
SIP_15_GRACE_PERIOD_END: Optional[date] = None # exclusive
SIP_15_DEFAULT_TIME_RANGE_ENDPOINTS = ["unknown", "inclusive"]
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>.'
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>.'
)
if CONFIG_PATH_ENV_VAR in os.environ:
# Explicitly import config module that is not necessarily in pythonpath; useful
@@ -749,7 +755,7 @@ if CONFIG_PATH_ENV_VAR in os.environ:
raise
elif importlib.util.find_spec("superset_config"):
try:
from superset_config import * # pylint: disable=import-error
from superset_config import * # pylint: disable=import-error,wildcard-import,unused-wildcard-import
import superset_config # pylint: disable=import-error
print(f"Loaded your LOCAL configuration at [{superset_config.__file__}]")

View File

@@ -14,20 +14,22 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=C,R,W
"""Contains the logic to create cohesive forms on the explore view"""
from typing import List # pylint: disable=unused-import
from flask_appbuilder.fieldwidgets import BS3TextFieldWidget
from wtforms import Field
class CommaSeparatedListField(Field):
widget = BS3TextFieldWidget()
data = [] # type: List[str]
def _value(self):
if self.data:
return u", ".join(self.data)
else:
return u""
return u""
def process_formdata(self, valuelist):
if valuelist:

View File

@@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=C,R,W
"""Code related with dealing with legacy / change management"""

View File

@@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=C,R,W
import logging
from logging.config import fileConfig
@@ -72,7 +71,9 @@ def run_migrations_online():
# this callback is used to prevent an auto-migration from being generated
# when there are no changes to the schema
# reference: https://alembic.sqlalchemy.org/en/latest/cookbook.html
def process_revision_directives(context, revision, directives):
def process_revision_directives(
context, revision, directives
): # pylint: disable=redefined-outer-name, unused-argument
if getattr(config.cmd_opts, "autogenerate", False):
script = directives[0]
if script.upgrade_ops.is_empty():

View File

@@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# pylint: disable=C,R,W
import logging
from colorama import Fore, Style
@@ -59,14 +58,9 @@ class DummyStatsLogger(BaseStatsLogger):
(Fore.CYAN + f"[stats_logger] (timing) {key} | {value} " + Style.RESET_ALL)
)
def gauge(self, key, value):
def gauge(self, key):
logging.debug(
(
Fore.CYAN
+ "[stats_logger] (gauge) "
+ f"{key} | {value}"
+ Style.RESET_ALL
)
(Fore.CYAN + "[stats_logger] (gauge) " + f"{key}" + Style.RESET_ALL)
)
@@ -74,7 +68,7 @@ try:
from statsd import StatsClient
class StatsdStatsLogger(BaseStatsLogger):
def __init__(
def __init__( # pylint: disable=super-init-not-called
self, host="localhost", port=8125, prefix="superset", statsd_client=None
):
"""
@@ -102,5 +96,5 @@ try:
self.client.gauge(key)
except Exception:
except Exception: # pylint: disable=broad-except
pass