removed explicit object inheritance (#6686)

* removed explicit object inheritance

* minor fix

* pr comments

---------

Co-authored-by: Andrew Chubatiuk <andrew.chubatiuk@motional.com>
This commit is contained in:
Andrii Chubatiuk
2024-01-05 12:52:02 +02:00
committed by GitHub
parent 998dc31eb0
commit cbde237b12
21 changed files with 25 additions and 25 deletions

View File

@@ -169,7 +169,7 @@ build-backend = "poetry.core.masonry.api"
[tool.ruff] [tool.ruff]
exclude = [".git", "viz-lib", "node_modules", "migrations"] exclude = [".git", "viz-lib", "node_modules", "migrations"]
ignore = ["E501"] ignore = ["E501"]
select = ["C9", "E", "F", "W", "I001"] select = ["C9", "E", "F", "W", "I001", "UP004"]
[tool.ruff.mccabe] [tool.ruff.mccabe]
max-complexity = 15 max-complexity = 15

View File

@@ -5,7 +5,7 @@ logger = logging.getLogger(__name__)
__all__ = ["BaseDestination", "register", "get_destination", "import_destinations"] __all__ = ["BaseDestination", "register", "get_destination", "import_destinations"]
class BaseDestination(object): class BaseDestination:
deprecated = False deprecated = False
def __init__(self, configuration): def __init__(self, configuration):

View File

@@ -80,7 +80,7 @@ from redash.utils.configuration import ConfigurationContainer
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class ScheduledQueriesExecutions(object): class ScheduledQueriesExecutions:
KEY_NAME = "sq:executed_at" KEY_NAME = "sq:executed_at"
def __init__(self): def __init__(self):
@@ -302,7 +302,7 @@ class DataSourceGroup(db.Model):
DESERIALIZED_DATA_ATTR = "_deserialized_data" DESERIALIZED_DATA_ATTR = "_deserialized_data"
class DBPersistence(object): class DBPersistence:
@property @property
def data(self): def data(self):
if self._data is None: if self._data is None:

View File

@@ -68,7 +68,7 @@ def gfk_type(cls):
return cls return cls
class GFKBase(object): class GFKBase:
""" """
Compatibility with 'generic foreign key' approach Peewee used. Compatibility with 'generic foreign key' approach Peewee used.
""" """

View File

@@ -45,7 +45,7 @@ class Change(GFKBase, db.Model):
) )
class ChangeTrackingMixin(object): class ChangeTrackingMixin:
skipped_fields = ("id", "created_at", "updated_at", "version") skipped_fields = ("id", "created_at", "updated_at", "version")
_clean_values = None _clean_values = None

View File

@@ -3,7 +3,7 @@ from sqlalchemy.event import listens_for
from .base import Column, db from .base import Column, db
class TimestampMixin(object): class TimestampMixin:
updated_at = Column(db.DateTime(True), default=db.func.now(), nullable=False) updated_at = Column(db.DateTime(True), default=db.func.now(), nullable=False)
created_at = Column(db.DateTime(True), default=db.func.now(), nullable=False) created_at = Column(db.DateTime(True), default=db.func.now(), nullable=False)
@@ -17,7 +17,7 @@ def timestamp_before_update(mapper, connection, target):
target.updated_at = db.func.now() target.updated_at = db.func.now()
class BelongsToOrgMixin(object): class BelongsToOrgMixin:
@classmethod @classmethod
def get_by_id_and_org(cls, object_id, org, org_cls=None): def get_by_id_and_org(cls, object_id, org, org_cls=None):
query = cls.query.filter(cls.id == object_id) query = cls.query.filter(cls.id == object_id)

View File

@@ -103,7 +103,7 @@ def _is_value_within_options(value, dropdown_options, allow_list=False):
return str(value) in dropdown_options return str(value) in dropdown_options
class ParameterizedQuery(object): class ParameterizedQuery:
def __init__(self, template, schema=None, org=None): def __init__(self, template, schema=None, org=None):
self.schema = schema or [] self.schema = schema or []
self.org = org self.org = org

View File

@@ -60,7 +60,7 @@ def init_app(app):
request_started.connect(update_user_active_at, app) request_started.connect(update_user_active_at, app)
class PermissionsCheckMixin(object): class PermissionsCheckMixin:
def has_permission(self, permission): def has_permission(self, permission):
return self.has_permissions((permission,)) return self.has_permissions((permission,))

View File

@@ -54,7 +54,7 @@ def require_access(obj, user, need_view_only):
abort(403) abort(403)
class require_permissions(object): class require_permissions:
def __init__(self, permissions, allow_one=False): def __init__(self, permissions, allow_one=False):
self.permissions = permissions self.permissions = permissions
self.allow_one = allow_one self.allow_one = allow_one

View File

@@ -114,7 +114,7 @@ class NotSupported(Exception):
pass pass
class BaseQueryRunner(object): class BaseQueryRunner:
deprecated = False deprecated = False
should_annotate_query = True should_annotate_query = True
noop_query = None noop_query = None

View File

@@ -47,7 +47,7 @@ _TYPE_MAPPINGS = {
} }
class SimpleFormatter(object): class SimpleFormatter:
def format(self, operation, parameters=None): def format(self, operation, parameters=None):
return operation return operation

View File

@@ -6,7 +6,7 @@ from redash.utils import json_dumps, json_loads
# TODO: make this more general and move into __init__.py # TODO: make this more general and move into __init__.py
class ResultSet(object): class ResultSet:
def __init__(self): def __init__(self):
self.columns = OrderedDict() self.columns = OrderedDict()
self.rows = [] self.rows = []

View File

@@ -44,7 +44,7 @@ types_map = {
} }
class Result(object): class Result:
def __init__(self): def __init__(self):
pass pass

View File

@@ -39,7 +39,7 @@ else:
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class CustomPrint(object): class CustomPrint:
"""CustomPrint redirect "print" calls to be sent as "log" on the result object.""" """CustomPrint redirect "print" calls to be sent as "log" on the result object."""
def __init__(self): def __init__(self):

View File

@@ -25,7 +25,7 @@ def _get_type(value):
# The following is here, because Rockset's PyPi package is Python 3 only. # The following is here, because Rockset's PyPi package is Python 3 only.
# Should be removed once we move to Python 3. # Should be removed once we move to Python 3.
class RocksetAPI(object): class RocksetAPI:
def __init__(self, api_key, api_server, vi_id): def __init__(self, api_key, api_server, vi_id):
self.api_key = api_key self.api_key = api_key
self.api_server = api_server self.api_server = api_server

View File

@@ -65,7 +65,7 @@ def public_dashboard(dashboard):
return dashboard_dict return dashboard_dict
class Serializer(object): class Serializer:
pass pass

View File

@@ -145,7 +145,7 @@ def _resolve_user(user_id, is_api_key, query_id):
return None return None
class QueryExecutor(object): class QueryExecutor:
def __init__(self, query, data_source_id, user_id, is_api_key, metadata, is_scheduled_query): def __init__(self, query, data_source_id, user_id, is_api_key, metadata, is_scheduled_query):
self.job = get_current_job() self.job = get_current_job()
self.query = query self.query = query

View File

@@ -7,7 +7,7 @@ from redash.utils import gen_query_hash, utcnow
from redash.utils.configuration import ConfigurationContainer from redash.utils.configuration import ConfigurationContainer
class ModelFactory(object): class ModelFactory:
def __init__(self, model, **kwargs): def __init__(self, model, **kwargs):
self.model = model self.model = model
self.kwargs = kwargs self.kwargs = kwargs
@@ -30,7 +30,7 @@ class ModelFactory(object):
return obj return obj
class Sequence(object): class Sequence:
def __init__(self, string): def __init__(self, string):
self.sequence = 0 self.sequence = 0
self.string = string self.string = string
@@ -172,7 +172,7 @@ query_snippet_factory = ModelFactory(
) )
class Factory(object): class Factory:
def __init__(self): def __init__(self):
self.org, self.admin_group, self.default_group = redash.models.init_db() self.org, self.admin_group, self.default_group = redash.models.init_db()
self._data_source = None self._data_source = None

View File

@@ -6,7 +6,7 @@ from werkzeug.exceptions import BadRequest
from redash.handlers.base import paginate from redash.handlers.base import paginate
class DummyResults(object): class DummyResults:
items = [i for i in range(25)] items = [i for i in range(25)]

View File

@@ -102,7 +102,7 @@ class TestUserListResourcePost(BaseTestCase):
class TestUserListGet(BaseTestCase): class TestUserListGet(BaseTestCase):
def create_filters_fixtures(self): def create_filters_fixtures(self):
class PlainObject(object): class PlainObject:
pass pass
result = PlainObject() result = PlainObject()

View File

@@ -6,7 +6,7 @@ from redash import models, settings
from tests import BaseTestCase, authenticated_user from tests import BaseTestCase, authenticated_user
class AuthenticationTestMixin(object): class AuthenticationTestMixin:
def test_returns_404_when_not_unauthenticated(self): def test_returns_404_when_not_unauthenticated(self):
for path in self.paths: for path in self.paths:
rv = self.client.get(path) rv = self.client.get(path)