From: Federico Caselli Date: Sun, 21 Nov 2021 19:36:35 +0000 (+0100) Subject: Remove object in class definition X-Git-Tag: rel_2_0_0b1~639 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b95f0055be252b13e99b0a944466f60b5e367ff;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Remove object in class definition References: #4600 Change-Id: I2a62ddfe00bc562720f0eae700a497495d7a987a --- diff --git a/doc/build/faq/sessions.rst b/doc/build/faq/sessions.rst index dc1336dad0..0c03080f47 100644 --- a/doc/build/faq/sessions.rst +++ b/doc/build/faq/sessions.rst @@ -329,7 +329,7 @@ method, which emits a `SELECT COUNT`. The reason this is not possible is because evaluating the query as a list would incur two SQL calls instead of one:: - class Iterates(object): + class Iterates: def __len__(self): print("LEN!") return 5 diff --git a/doc/build/orm/collections.rst b/doc/build/orm/collections.rst index bc98b4b41d..a811779afa 100644 --- a/doc/build/orm/collections.rst +++ b/doc/build/orm/collections.rst @@ -453,7 +453,7 @@ interface are detected and instrumented via duck-typing: .. sourcecode:: python+sql - class ListLike(object): + class ListLike: def __init__(self): self.data = [] def append(self, item): @@ -475,7 +475,7 @@ Duck-typing (i.e. guesswork) isn't rock-solid, of course, so you can be explicit about the interface you are implementing by providing an ``__emulates__`` class attribute:: - class SetLike(object): + class SetLike: __emulates__ = set def __init__(self): @@ -511,7 +511,7 @@ get the job done. from sqlalchemy.orm.collections import collection - class SetLike(object): + class SetLike: __emulates__ = set def __init__(self): diff --git a/doc/build/orm/composites.rst b/doc/build/orm/composites.rst index fb3ca47678..0628f56aef 100644 --- a/doc/build/orm/composites.rst +++ b/doc/build/orm/composites.rst @@ -12,7 +12,7 @@ class you provide. A simple example represents pairs of columns as a ``Point`` object. ``Point`` represents such a pair as ``.x`` and ``.y``:: - class Point(object): + class Point: def __init__(self, x, y): self.x = x self.y = y @@ -155,7 +155,7 @@ itself be a composite object, which is then mapped to a class ``HasVertex``:: from sqlalchemy.orm import composite - class Point(object): + class Point: def __init__(self, x, y): self.x = x self.y = y @@ -174,7 +174,7 @@ itself be a composite object, which is then mapped to a class ``HasVertex``:: def __ne__(self, other): return not self.__eq__(other) - class Vertex(object): + class Vertex: def __init__(self, start, end): self.start = start self.end = end diff --git a/doc/build/orm/constructors.rst b/doc/build/orm/constructors.rst index b78b0f0cb9..c55d381c50 100644 --- a/doc/build/orm/constructors.rst +++ b/doc/build/orm/constructors.rst @@ -29,7 +29,7 @@ useful for recreating transient properties that are normally assigned in from sqlalchemy import orm - class MyMappedClass(object): + class MyMappedClass: def __init__(self, data): self.data = data # we need stuff on all instances, but not in the database. diff --git a/doc/build/orm/declarative_config.rst b/doc/build/orm/declarative_config.rst index 9240d9011b..4a091c8483 100644 --- a/doc/build/orm/declarative_config.rst +++ b/doc/build/orm/declarative_config.rst @@ -360,7 +360,7 @@ Allows the callable / class used to generate a :class:`_schema.Table` to be cust This is a very open-ended hook that can allow special customizations to a :class:`_schema.Table` that one generates here:: - class MyMixin(object): + class MyMixin: @classmethod def __table_cls__(cls, name, metadata_obj, *arg, **kw): return Table( @@ -378,7 +378,7 @@ This may be useful in some customization schemes to determine that single-table inheritance should take place based on the arguments for the table itself, such as, define as single-inheritance if there is no primary key present:: - class AutoTable(object): + class AutoTable: @declared_attr def __tablename__(cls): return cls.__name__ diff --git a/doc/build/orm/inheritance.rst b/doc/build/orm/inheritance.rst index eafbba342a..cb3ccfd8d2 100644 --- a/doc/build/orm/inheritance.rst +++ b/doc/build/orm/inheritance.rst @@ -859,7 +859,7 @@ Alternatively, the same :class:`_schema.Table` objects can be used in fully "classical" style, without using Declarative at all. A constructor similar to that supplied by Declarative is illustrated:: - class Employee(object): + class Employee: def __init__(self, **kw): for k in kw: setattr(self, k, kw[k]) diff --git a/doc/build/orm/join_conditions.rst b/doc/build/orm/join_conditions.rst index af314f221e..a6d0309918 100644 --- a/doc/build/orm/join_conditions.rst +++ b/doc/build/orm/join_conditions.rst @@ -609,7 +609,7 @@ to ``node.c.id``:: Column('id', Integer, primary_key=True), Column('label', String) ) - class Node(object): + class Node: pass mapper_registry.map_imperatively(Node, node, properties={ diff --git a/doc/build/orm/mapping_styles.rst b/doc/build/orm/mapping_styles.rst index e643cfce63..723b540684 100644 --- a/doc/build/orm/mapping_styles.rst +++ b/doc/build/orm/mapping_styles.rst @@ -419,7 +419,7 @@ constructs that can't be easily duplicated must be given as callables, using the :class:`_orm.declared_attr` decorator, such as in the example at :ref:`orm_declarative_mixins_relationships`:: - class RefTargetMixin(object): + class RefTargetMixin: @declared_attr def target_id(cls): return Column('target_id', ForeignKey('target.id')) diff --git a/doc/build/orm/session_basics.rst b/doc/build/orm/session_basics.rst index fce6d4919d..6f818a439b 100644 --- a/doc/build/orm/session_basics.rst +++ b/doc/build/orm/session_basics.rst @@ -956,7 +956,7 @@ E.g. **don't do this**:: ### this is the **wrong way to do it** ### - class ThingOne(object): + class ThingOne: def go(self): session = Session() try: @@ -966,7 +966,7 @@ E.g. **don't do this**:: session.rollback() raise - class ThingTwo(object): + class ThingTwo: def go(self): session = Session() try: @@ -988,11 +988,11 @@ transaction automatically:: ### this is a **better** (but not the only) way to do it ### - class ThingOne(object): + class ThingOne: def go(self, session): session.query(FooBar).update({"x": 5}) - class ThingTwo(object): + class ThingTwo: def go(self, session): session.query(Widget).update({"q": 18}) diff --git a/doc/build/orm/session_events.rst b/doc/build/orm/session_events.rst index 544a6c5773..430471f4f5 100644 --- a/doc/build/orm/session_events.rst +++ b/doc/build/orm/session_events.rst @@ -114,7 +114,7 @@ Given a series of classes based on a mixin called ``HasTimestamp``:: import datetime - class HasTimestamp(object): + class HasTimestamp: timestamp = Column(DateTime, default=datetime.datetime.now) diff --git a/examples/association/dict_of_sets_with_default.py b/examples/association/dict_of_sets_with_default.py index 435761d3f7..14045b7f56 100644 --- a/examples/association/dict_of_sets_with_default.py +++ b/examples/association/dict_of_sets_with_default.py @@ -26,7 +26,7 @@ from sqlalchemy.orm import Session from sqlalchemy.orm.collections import MappedCollection -class Base(object): +class Base: id = Column(Integer, primary_key=True) diff --git a/examples/custom_attributes/custom_management.py b/examples/custom_attributes/custom_management.py index 6cddfe7bd1..5ee5a45f83 100644 --- a/examples/custom_attributes/custom_management.py +++ b/examples/custom_attributes/custom_management.py @@ -43,7 +43,7 @@ class MyClassState(InstrumentationManager): return find -class MyClass(object): +class MyClass: __sa_instrumentation_manager__ = MyClassState def __init__(self, **kwargs): diff --git a/examples/custom_attributes/listen_for_events.py b/examples/custom_attributes/listen_for_events.py index e3ef4cbea8..b2d2b690b6 100644 --- a/examples/custom_attributes/listen_for_events.py +++ b/examples/custom_attributes/listen_for_events.py @@ -27,7 +27,7 @@ if __name__ == "__main__": from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declarative_base - class Base(object): + class Base: def receive_change_event(self, verb, key, value, oldvalue): s = "Value '%s' %s on attribute '%s', " % (value, verb, key) if oldvalue: diff --git a/examples/dogpile_caching/caching_query.py b/examples/dogpile_caching/caching_query.py index 68f72e5f06..dc007a7602 100644 --- a/examples/dogpile_caching/caching_query.py +++ b/examples/dogpile_caching/caching_query.py @@ -26,7 +26,7 @@ from sqlalchemy.orm import loading from sqlalchemy.orm.interfaces import UserDefinedOption -class ORMCache(object): +class ORMCache: """An add-on for an ORM :class:`.Session` optionally loads full results from a dogpile cache region. diff --git a/examples/dynamic_dict/dynamic_dict.py b/examples/dynamic_dict/dynamic_dict.py index 63a23bffb1..f8dc080ffe 100644 --- a/examples/dynamic_dict/dynamic_dict.py +++ b/examples/dynamic_dict/dynamic_dict.py @@ -8,7 +8,7 @@ from sqlalchemy.orm import relationship from sqlalchemy.orm import sessionmaker -class ProxyDict(object): +class ProxyDict: def __init__(self, parent, collection_name, childclass, keyname): self.parent = parent self.collection_name = collection_name diff --git a/examples/elementtree/adjacency_list.py b/examples/elementtree/adjacency_list.py index 43961fb41d..9d2c78157e 100644 --- a/examples/elementtree/adjacency_list.py +++ b/examples/elementtree/adjacency_list.py @@ -89,7 +89,7 @@ mapper_registry.metadata.create_all(e) # and the ElementTree root element. -class Document(object): +class Document: def __init__(self, name, element): self.filename = name self.element = element @@ -103,7 +103,7 @@ class Document(object): # may be backed by native implementations. so here we construct an adapter. -class _Node(object): +class _Node: pass @@ -111,7 +111,7 @@ class _Node(object): # stored for a particular Node. -class _Attribute(object): +class _Attribute: def __init__(self, name, value): self.name = name self.value = value @@ -144,7 +144,7 @@ mapper(_Attribute, attributes) # collection. -class ElementTreeMarshal(object): +class ElementTreeMarshal: def __get__(self, document, owner): if document is None: return self diff --git a/examples/elementtree/optimized_al.py b/examples/elementtree/optimized_al.py index c68720aaa5..1c16e1c8a4 100644 --- a/examples/elementtree/optimized_al.py +++ b/examples/elementtree/optimized_al.py @@ -80,7 +80,7 @@ mapper_registry.metadata.create_all(e) # and the ElementTree root element. -class Document(object): +class Document: def __init__(self, name, element): self.filename = name self.element = element @@ -94,7 +94,7 @@ class Document(object): # may be backed by native implementations. so here we construct an adapter. -class _Node(object): +class _Node: pass @@ -102,7 +102,7 @@ class _Node(object): # stored for a particular Node. -class _Attribute(object): +class _Attribute: def __init__(self, name, value): self.name = name self.value = value @@ -147,7 +147,7 @@ mapper(_Attribute, attributes) # collection. -class ElementTreeMarshal(object): +class ElementTreeMarshal: def __get__(self, document, owner): if document is None: return self diff --git a/examples/elementtree/pickle_type.py b/examples/elementtree/pickle_type.py index cde517db36..e96a128b36 100644 --- a/examples/elementtree/pickle_type.py +++ b/examples/elementtree/pickle_type.py @@ -51,7 +51,7 @@ mapper_registry.metadata.create_all(e) # and the ElementTree root element. -class Document(object): +class Document: def __init__(self, name, element): self.filename = name self.element = element diff --git a/examples/extending_query/filter_public.py b/examples/extending_query/filter_public.py index 53472e95a3..08a0d273db 100644 --- a/examples/extending_query/filter_public.py +++ b/examples/extending_query/filter_public.py @@ -50,7 +50,7 @@ def _add_filtering_criteria(execute_state): ) -class HasPrivate(object): +class HasPrivate: """Mixin that identifies a class as having private entities""" public = Column(Boolean, nullable=False) diff --git a/examples/extending_query/temporal_range.py b/examples/extending_query/temporal_range.py index 3706877469..3a6570ad1e 100644 --- a/examples/extending_query/temporal_range.py +++ b/examples/extending_query/temporal_range.py @@ -11,7 +11,7 @@ from sqlalchemy import DateTime from sqlalchemy import orm -class HasTemporal(object): +class HasTemporal: """Mixin that identifies a class as having a timestamp column""" timestamp = Column( diff --git a/examples/generic_associations/discriminator_on_association.py b/examples/generic_associations/discriminator_on_association.py index 9502088464..f0f1d7ed99 100644 --- a/examples/generic_associations/discriminator_on_association.py +++ b/examples/generic_associations/discriminator_on_association.py @@ -29,7 +29,7 @@ from sqlalchemy.orm import Session @as_declarative() -class Base(object): +class Base: """Base class which provides automated table name and surrogate primary key column. @@ -81,7 +81,7 @@ class Address(Base): ) -class HasAddresses(object): +class HasAddresses: """HasAddresses mixin, creates a relationship to the address_association table for each parent. diff --git a/examples/generic_associations/generic_fk.py b/examples/generic_associations/generic_fk.py index 23145ed4c6..1cd0404e9f 100644 --- a/examples/generic_associations/generic_fk.py +++ b/examples/generic_associations/generic_fk.py @@ -35,7 +35,7 @@ from sqlalchemy.orm import Session @as_declarative() -class Base(object): +class Base: """Base class which provides automated table name and surrogate primary key column. @@ -86,7 +86,7 @@ class Address(Base): ) -class HasAddresses(object): +class HasAddresses: """HasAddresses mixin, creates a relationship to the address_association table for each parent. diff --git a/examples/generic_associations/table_per_association.py b/examples/generic_associations/table_per_association.py index 98c76ef7be..2e412869f0 100644 --- a/examples/generic_associations/table_per_association.py +++ b/examples/generic_associations/table_per_association.py @@ -24,7 +24,7 @@ from sqlalchemy.orm import Session @as_declarative() -class Base(object): +class Base: """Base class which provides automated table name and surrogate primary key column. @@ -58,7 +58,7 @@ class Address(Base): ) -class HasAddresses(object): +class HasAddresses: """HasAddresses mixin, creates a new address_association table for each parent. diff --git a/examples/generic_associations/table_per_related.py b/examples/generic_associations/table_per_related.py index 3f09e538b0..5b83e6e68f 100644 --- a/examples/generic_associations/table_per_related.py +++ b/examples/generic_associations/table_per_related.py @@ -28,7 +28,7 @@ from sqlalchemy.orm import Session @as_declarative() -class Base(object): +class Base: """Base class which provides automated table name and surrogate primary key column. @@ -41,7 +41,7 @@ class Base(object): id = Column(Integer, primary_key=True) -class Address(object): +class Address: """Define columns that will be present in each 'Address' table. @@ -64,7 +64,7 @@ class Address(object): ) -class HasAddresses(object): +class HasAddresses: """HasAddresses mixin, creates a new Address class for each parent. diff --git a/examples/large_collection/large_collection.py b/examples/large_collection/large_collection.py index 2b8c57232a..b2ba1b6ae3 100644 --- a/examples/large_collection/large_collection.py +++ b/examples/large_collection/large_collection.py @@ -34,12 +34,12 @@ member_table = Table( ) -class Organization(object): +class Organization: def __init__(self, name): self.name = name -class Member(object): +class Member: def __init__(self, name): self.name = name diff --git a/examples/performance/__init__.py b/examples/performance/__init__.py index b6c74d7fe9..bdf8e841db 100644 --- a/examples/performance/__init__.py +++ b/examples/performance/__init__.py @@ -215,7 +215,7 @@ import sys import time -class Profiler(object): +class Profiler: tests = [] _setup = None @@ -400,7 +400,7 @@ class Profiler(object): return suites -class TestResult(object): +class TestResult: def __init__( self, profile, test, stats=None, total_time=None, sort="cumulative" ): diff --git a/examples/performance/large_resultsets.py b/examples/performance/large_resultsets.py index b7b96453d9..ac1b98b6f5 100644 --- a/examples/performance/large_resultsets.py +++ b/examples/performance/large_resultsets.py @@ -168,7 +168,7 @@ def _test_dbapi_raw(n, make_objects): # because if you're going to roll your own, you're probably # going to do this, so see how this pushes you right back into # ORM land anyway :) - class SimpleCustomer(object): + class SimpleCustomer: def __init__(self, id_, name, description): self.id_ = id_ self.name = name diff --git a/examples/postgis/postgis.py b/examples/postgis/postgis.py index 2b45b98f56..06df2ce662 100644 --- a/examples/postgis/postgis.py +++ b/examples/postgis/postgis.py @@ -10,7 +10,7 @@ from sqlalchemy.types import UserDefinedType # Python datatypes -class GisElement(object): +class GisElement: """Represents a geometry value.""" def __str__(self): diff --git a/examples/versioned_history/history_meta.py b/examples/versioned_history/history_meta.py index 7d13f2d745..214f75e6b6 100644 --- a/examples/versioned_history/history_meta.py +++ b/examples/versioned_history/history_meta.py @@ -173,7 +173,7 @@ def _history_mapper(local_mapper): local_mapper.version_id_col = local_mapper.local_table.c.version -class Versioned(object): +class Versioned: use_mapper_versioning = False """if True, also assign the version column to be tracked by the mapper""" diff --git a/examples/versioned_rows/versioned_rows.py b/examples/versioned_rows/versioned_rows.py index 7179d04749..96d2e399ec 100644 --- a/examples/versioned_rows/versioned_rows.py +++ b/examples/versioned_rows/versioned_rows.py @@ -18,7 +18,7 @@ from sqlalchemy.orm import Session from sqlalchemy.orm import sessionmaker -class Versioned(object): +class Versioned: def new_version(self, session): # make us transient (removes persistent # identity). diff --git a/examples/versioned_rows/versioned_rows_w_versionid.py b/examples/versioned_rows/versioned_rows_w_versionid.py index 87d246da1d..39cbaf1aa6 100644 --- a/examples/versioned_rows/versioned_rows_w_versionid.py +++ b/examples/versioned_rows/versioned_rows_w_versionid.py @@ -25,7 +25,7 @@ from sqlalchemy.orm import Session from sqlalchemy.orm import sessionmaker -class Versioned(object): +class Versioned: # we have a composite primary key consisting of "id" # and "version_id" id = Column(Integer, primary_key=True) diff --git a/examples/versioned_rows/versioned_update_old_row.py b/examples/versioned_rows/versioned_update_old_row.py index 049c1a7a02..e1e25704c9 100644 --- a/examples/versioned_rows/versioned_update_old_row.py +++ b/examples/versioned_rows/versioned_update_old_row.py @@ -37,7 +37,7 @@ def current_time(): return now -class VersionedStartEnd(object): +class VersionedStartEnd: start = Column(DateTime, primary_key=True) end = Column(DateTime, primary_key=True) diff --git a/examples/vertical/dictlike-polymorphic.py b/examples/vertical/dictlike-polymorphic.py index 4c81af6d54..95b582a761 100644 --- a/examples/vertical/dictlike-polymorphic.py +++ b/examples/vertical/dictlike-polymorphic.py @@ -31,7 +31,7 @@ from sqlalchemy.orm.interfaces import PropComparator from .dictlike import ProxiedDictMixin -class PolymorphicVerticalProperty(object): +class PolymorphicVerticalProperty: """A key/value pair with polymorphic value storage. The class which is mapped should indicate typing information diff --git a/examples/vertical/dictlike.py b/examples/vertical/dictlike.py index f1f3642079..9d2eb4a229 100644 --- a/examples/vertical/dictlike.py +++ b/examples/vertical/dictlike.py @@ -33,7 +33,7 @@ can be used with many common vertical schemas as-is or with minor adaptations. from __future__ import unicode_literals -class ProxiedDictMixin(object): +class ProxiedDictMixin: """Adds obj[key] access to a mapped class. This class basically proxies dictionary access to an attribute diff --git a/lib/sqlalchemy/connectors/__init__.py b/lib/sqlalchemy/connectors/__init__.py index fee8b3836f..eaa3e1a58f 100644 --- a/lib/sqlalchemy/connectors/__init__.py +++ b/lib/sqlalchemy/connectors/__init__.py @@ -6,5 +6,5 @@ # the MIT License: https://www.opensource.org/licenses/mit-license.php -class Connector(object): +class Connector: pass diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py index 974cae4f7e..e5745bf698 100644 --- a/lib/sqlalchemy/dialects/mssql/base.py +++ b/lib/sqlalchemy/dialects/mssql/base.py @@ -1146,7 +1146,7 @@ class _BASETIMEIMPL(TIME): __visit_name__ = "_BASETIMEIMPL" -class _DateTimeBase(object): +class _DateTimeBase: def bind_processor(self, dialect): def process(value): if type(value) == datetime.date: @@ -1181,7 +1181,7 @@ class DATETIMEOFFSET(_DateTimeBase, sqltypes.DateTime): self.precision = precision -class _UnicodeLiteral(object): +class _UnicodeLiteral: def literal_processor(self, dialect): def process(value): diff --git a/lib/sqlalchemy/dialects/mssql/json.py b/lib/sqlalchemy/dialects/mssql/json.py index d5157312c7..ae90597771 100644 --- a/lib/sqlalchemy/dialects/mssql/json.py +++ b/lib/sqlalchemy/dialects/mssql/json.py @@ -77,7 +77,7 @@ class JSON(sqltypes.JSON): # Note: these objects currently match exactly those of MySQL, however since # these are not generalizable to all JSON implementations, remain separately # implemented for each dialect. -class _FormatTypeMixin(object): +class _FormatTypeMixin: def _format_value(self, value): raise NotImplementedError() diff --git a/lib/sqlalchemy/dialects/mssql/pyodbc.py b/lib/sqlalchemy/dialects/mssql/pyodbc.py index 0a56a03de6..6ce55d3925 100644 --- a/lib/sqlalchemy/dialects/mssql/pyodbc.py +++ b/lib/sqlalchemy/dialects/mssql/pyodbc.py @@ -294,7 +294,7 @@ from ... import util from ...connectors.pyodbc import PyODBCConnector -class _ms_numeric_pyodbc(object): +class _ms_numeric_pyodbc: """Turns Decimals with adjusted() < 0 or > 7 into strings. @@ -366,7 +366,7 @@ class _MSFloat_pyodbc(_ms_numeric_pyodbc, sqltypes.Float): pass -class _ms_binary_pyodbc(object): +class _ms_binary_pyodbc: """Wraps binary values in dialect-specific Binary wrapper. If the value is null, return a pyodbc-specific BinaryNull object to prevent pyODBC [and FreeTDS] from defaulting binary @@ -389,7 +389,7 @@ class _ms_binary_pyodbc(object): return process -class _ODBCDateTimeBindProcessor(object): +class _ODBCDateTimeBindProcessor: """Add bind processors to handle datetimeoffset behaviors""" has_tz = False diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index af2d7bdbbf..54fe1f57f8 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -3196,7 +3196,7 @@ class MySQLDialect(default.DefaultDialect): return rows -class _DecodingRow(object): +class _DecodingRow: """Return unicode-decoded values based on type inspection. Smooth over data type issues (esp. with alpha driver versions) and diff --git a/lib/sqlalchemy/dialects/mysql/json.py b/lib/sqlalchemy/dialects/mysql/json.py index 8d052cc7c0..384d3b9b62 100644 --- a/lib/sqlalchemy/dialects/mysql/json.py +++ b/lib/sqlalchemy/dialects/mysql/json.py @@ -36,7 +36,7 @@ class JSON(sqltypes.JSON): pass -class _FormatTypeMixin(object): +class _FormatTypeMixin: def _format_value(self, value): raise NotImplementedError() diff --git a/lib/sqlalchemy/dialects/mysql/reflection.py b/lib/sqlalchemy/dialects/mysql/reflection.py index 503c9614c0..8d5b24f0ca 100644 --- a/lib/sqlalchemy/dialects/mysql/reflection.py +++ b/lib/sqlalchemy/dialects/mysql/reflection.py @@ -17,7 +17,7 @@ from ... import types as sqltypes from ... import util -class ReflectedState(object): +class ReflectedState: """Stores raw information about a SHOW CREATE TABLE statement.""" def __init__(self): @@ -30,7 +30,7 @@ class ReflectedState(object): @log.class_logger -class MySQLTableDefinitionParser(object): +class MySQLTableDefinitionParser: """Parses the results of a SHOW CREATE TABLE statement.""" def __init__(self, dialect, preparer): diff --git a/lib/sqlalchemy/dialects/mysql/types.py b/lib/sqlalchemy/dialects/mysql/types.py index dee58b4a53..abbf943a9a 100644 --- a/lib/sqlalchemy/dialects/mysql/types.py +++ b/lib/sqlalchemy/dialects/mysql/types.py @@ -12,7 +12,7 @@ from ... import types as sqltypes from ... import util -class _NumericType(object): +class _NumericType: """Base for MySQL numeric types. This is the base both for NUMERIC as well as INTEGER, hence diff --git a/lib/sqlalchemy/dialects/postgresql/ranges.py b/lib/sqlalchemy/dialects/postgresql/ranges.py index c54179c818..d141ee731c 100644 --- a/lib/sqlalchemy/dialects/postgresql/ranges.py +++ b/lib/sqlalchemy/dialects/postgresql/ranges.py @@ -10,7 +10,7 @@ from ... import types as sqltypes __all__ = ("INT4RANGE", "INT8RANGE", "NUMRANGE") -class RangeOperators(object): +class RangeOperators: """ This mixin provides functionality for the Range Operators listed in Table 9-44 of the `PostgreSQL documentation`__ for Range diff --git a/lib/sqlalchemy/dialects/sqlite/base.py b/lib/sqlalchemy/dialects/sqlite/base.py index 6c22c8ef3a..7ded739733 100644 --- a/lib/sqlalchemy/dialects/sqlite/base.py +++ b/lib/sqlalchemy/dialects/sqlite/base.py @@ -863,7 +863,7 @@ class _SQliteJson(JSON): return process -class _DateTimeMixin(object): +class _DateTimeMixin: _reg = None _storage_format = None diff --git a/lib/sqlalchemy/dialects/sqlite/json.py b/lib/sqlalchemy/dialects/sqlite/json.py index 614f95405f..b412fa5a52 100644 --- a/lib/sqlalchemy/dialects/sqlite/json.py +++ b/lib/sqlalchemy/dialects/sqlite/json.py @@ -36,7 +36,7 @@ class JSON(sqltypes.JSON): # Note: these objects currently match exactly those of MySQL, however since # these are not generalizable to all JSON implementations, remain separately # implemented for each dialect. -class _FormatTypeMixin(object): +class _FormatTypeMixin: def _format_value(self, value): raise NotImplementedError() diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index 24f8a8a87b..389270e459 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -2603,7 +2603,7 @@ class Engine(ConnectionEventsTarget, log.Identified): return self.pool.connect() -class OptionEngineMixin(object): +class OptionEngineMixin: _sa_propagate_class_events = False def __init__(self, proxied, execution_options): diff --git a/lib/sqlalchemy/engine/cursor.py b/lib/sqlalchemy/engine/cursor.py index 0099d69ffa..54db9f6c27 100644 --- a/lib/sqlalchemy/engine/cursor.py +++ b/lib/sqlalchemy/engine/cursor.py @@ -692,7 +692,7 @@ class CursorResultMetaData(ResultMetaData): self._translated_indexes = self._tuplefilter = None -class ResultFetchStrategy(object): +class ResultFetchStrategy: """Define a fetching strategy for a result object. @@ -1095,7 +1095,7 @@ class _NoResultMetaData(ResultMetaData): _NO_RESULT_METADATA = _NoResultMetaData() -class BaseCursorResult(object): +class BaseCursorResult: """Base class for database result objects.""" out_parameters = None diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py index 9a138e69e7..3af24d9135 100644 --- a/lib/sqlalchemy/engine/default.py +++ b/lib/sqlalchemy/engine/default.py @@ -674,7 +674,7 @@ class DefaultDialect(interfaces.Dialect): return connection -class _RendersLiteral(object): +class _RendersLiteral: def literal_processor(self, dialect): def process(value): return "'%s'" % value diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py index 7150f386c5..6772a27bda 100644 --- a/lib/sqlalchemy/engine/interfaces.py +++ b/lib/sqlalchemy/engine/interfaces.py @@ -11,7 +11,7 @@ from ..sql.compiler import Compiled # noqa from ..sql.compiler import TypeCompiler # noqa -class Dialect(object): +class Dialect: """Define the behavior of a specific database and DB-API combination. Any aspect of metadata definition, SQL query generation, @@ -1109,7 +1109,7 @@ class Dialect(object): raise NotImplementedError() -class CreateEnginePlugin(object): +class CreateEnginePlugin: """A set of hooks intended to augment the construction of an :class:`_engine.Engine` object based on entrypoint names in a URL. @@ -1343,7 +1343,7 @@ class CreateEnginePlugin(object): """ -class ExecutionContext(object): +class ExecutionContext: """A messenger object for a Dialect that corresponds to a single execution. @@ -1601,7 +1601,7 @@ class Connectable(ConnectionEventsTarget): raise NotImplementedError() -class ExceptionContext(object): +class ExceptionContext: """Encapsulate information about an error condition in progress. This object exists solely to be passed to the @@ -1750,7 +1750,7 @@ class ExceptionContext(object): """ -class AdaptedConnection(object): +class AdaptedConnection: """Interface of an adapted connection object to support the DBAPI protocol. Used by asyncio dialects to provide a sync-style pep-249 facade on top diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index fed353e9cd..c918f15b3c 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -58,7 +58,7 @@ def cache(fn, self, con, *args, **kw): @inspection._self_inspects -class Inspector(object): +class Inspector: """Performs database schema inspection. The Inspector acts as a proxy to the reflection methods of the diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py index 113cdcf352..4187c6c13a 100644 --- a/lib/sqlalchemy/engine/result.py +++ b/lib/sqlalchemy/engine/result.py @@ -35,7 +35,7 @@ else: return lambda row: (it(row),) -class ResultMetaData(object): +class ResultMetaData: """Base for metadata about result rows.""" __slots__ = () @@ -655,7 +655,7 @@ class ResultInternal(InPlaceGenerative): return uniques, strategy -class _WithKeys(object): +class _WithKeys: # used mainly to share documentation on the keys method. def keys(self): """Return an iterable view which yields the string keys that would @@ -1516,7 +1516,7 @@ class MappingResult(_WithKeys, FilterResult): ) -class FrozenResult(object): +class FrozenResult: """Represents a :class:`.Result` object in a "frozen" state suitable for caching. diff --git a/lib/sqlalchemy/engine/row.py b/lib/sqlalchemy/engine/row.py index e268cfec90..782fc21b8b 100644 --- a/lib/sqlalchemy/engine/row.py +++ b/lib/sqlalchemy/engine/row.py @@ -53,7 +53,7 @@ try: except ImportError: _baserow_usecext = False - class BaseRow(object): + class BaseRow: __slots__ = ("_parent", "_data", "_keymap", "_key_style") def __init__(self, parent, processors, keymap, key_style, data): diff --git a/lib/sqlalchemy/engine/strategies.py b/lib/sqlalchemy/engine/strategies.py index bda1c7fae9..a1d76f2b0a 100644 --- a/lib/sqlalchemy/engine/strategies.py +++ b/lib/sqlalchemy/engine/strategies.py @@ -13,5 +13,5 @@ from .mock import MockConnection # noqa -class MockEngineStrategy(object): +class MockEngineStrategy: MockConnection = MockConnection diff --git a/lib/sqlalchemy/engine/util.py b/lib/sqlalchemy/engine/util.py index 36691504c5..4467bafd35 100644 --- a/lib/sqlalchemy/engine/util.py +++ b/lib/sqlalchemy/engine/util.py @@ -81,7 +81,7 @@ def _distill_raw_params(params): raise exc.ArgumentError("mapping or sequence expected for parameters") -class TransactionalContext(object): +class TransactionalContext: """Apply Python context manager behavior to transaction objects. Performs validation to ensure the subject of the transaction is not diff --git a/lib/sqlalchemy/event/attr.py b/lib/sqlalchemy/event/attr.py index a0c2992213..77eb0472c7 100644 --- a/lib/sqlalchemy/event/attr.py +++ b/lib/sqlalchemy/event/attr.py @@ -51,7 +51,7 @@ class RefCollection(util.MemoizedSlots): return weakref.ref(self, registry._collection_gced) -class _empty_collection(object): +class _empty_collection: def append(self, element): pass diff --git a/lib/sqlalchemy/event/base.py b/lib/sqlalchemy/event/base.py index f8cbfbd7f6..b084207b4e 100644 --- a/lib/sqlalchemy/event/base.py +++ b/lib/sqlalchemy/event/base.py @@ -38,7 +38,7 @@ def _is_event_name(name): ) or name.startswith("_sa_event") -class _UnpickleDispatch(object): +class _UnpickleDispatch: """Serializable callable that re-generates an instance of :class:`_Dispatch` given a particular :class:`.Events` subclass. @@ -54,7 +54,7 @@ class _UnpickleDispatch(object): raise AttributeError("No class with a 'dispatch' member present.") -class _Dispatch(object): +class _Dispatch: """Mirror the event listening definitions of an Events class with listener collections. @@ -275,7 +275,7 @@ class Events(util.with_metaclass(_EventMeta, object)): cls.dispatch._clear() -class _JoinedDispatcher(object): +class _JoinedDispatcher: """Represent a connection between two _Dispatch objects.""" __slots__ = "local", "parent", "_instance_cls" @@ -302,7 +302,7 @@ class _JoinedDispatcher(object): return self.parent._events -class dispatcher(object): +class dispatcher: """Descriptor used by target classes to deliver the _Dispatch class at the class level and produce new _Dispatch instances for target diff --git a/lib/sqlalchemy/event/registry.py b/lib/sqlalchemy/event/registry.py index ca85f33684..d81f27cd48 100644 --- a/lib/sqlalchemy/event/registry.py +++ b/lib/sqlalchemy/event/registry.py @@ -148,7 +148,7 @@ def _clear(owner, elements): del _key_to_collection[key] -class _EventKey(object): +class _EventKey: """Represent :func:`.listen` arguments.""" __slots__ = ( diff --git a/lib/sqlalchemy/exc.py b/lib/sqlalchemy/exc.py index 7fa77120c6..ef246d04fb 100644 --- a/lib/sqlalchemy/exc.py +++ b/lib/sqlalchemy/exc.py @@ -19,7 +19,7 @@ from .util import compat _version_token = None -class HasDescriptionCode(object): +class HasDescriptionCode: """helper which adds 'code' as an attribute and '_code_str' as a method""" code = None @@ -375,7 +375,7 @@ class UnboundExecutionError(InvalidRequestError): """SQL was attempted without a database connection to execute it on.""" -class DontWrapMixin(object): +class DontWrapMixin: """A mixin class which, when applied to a user-defined Exception class, will not be wrapped inside of :exc:`.StatementError` if the error is emitted within the process of executing a statement. diff --git a/lib/sqlalchemy/ext/associationproxy.py b/lib/sqlalchemy/ext/associationproxy.py index a93f2c2290..0aa836a3c7 100644 --- a/lib/sqlalchemy/ext/associationproxy.py +++ b/lib/sqlalchemy/ext/associationproxy.py @@ -306,7 +306,7 @@ class AssociationProxy(interfaces.InspectionAttrInfo): ) -class AssociationProxyInstance(object): +class AssociationProxyInstance: """A per-class object that serves class- and object-specific results. This is used by :class:`.AssociationProxy` when it is invoked @@ -936,7 +936,7 @@ class ColumnAssociationProxyInstance( ) -class _lazy_collection(object): +class _lazy_collection: def __init__(self, obj, target): self.parent = obj self.target = target @@ -952,7 +952,7 @@ class _lazy_collection(object): self.target = state["target"] -class _AssociationCollection(object): +class _AssociationCollection: def __init__(self, lazy_collection, creator, getter, setter, parent): """Constructs an _AssociationCollection. diff --git a/lib/sqlalchemy/ext/automap.py b/lib/sqlalchemy/ext/automap.py index 7cb2c4400b..b62c514c7b 100644 --- a/lib/sqlalchemy/ext/automap.py +++ b/lib/sqlalchemy/ext/automap.py @@ -717,7 +717,7 @@ def generate_relationship( raise TypeError("Unknown relationship function: %s" % return_fn) -class AutomapBase(object): +class AutomapBase: """Base class for an "automap" schema. The :class:`.AutomapBase` class can be compared to the "declarative base" diff --git a/lib/sqlalchemy/ext/baked.py b/lib/sqlalchemy/ext/baked.py index 61328fce95..efdafff968 100644 --- a/lib/sqlalchemy/ext/baked.py +++ b/lib/sqlalchemy/ext/baked.py @@ -30,7 +30,7 @@ from ..util import collections_abc log = logging.getLogger(__name__) -class Bakery(object): +class Bakery: """Callable which returns a :class:`.BakedQuery`. This object is returned by the class method @@ -52,7 +52,7 @@ class Bakery(object): return self.cls(self.cache, initial_fn, args) -class BakedQuery(object): +class BakedQuery: """A builder object for :class:`.query.Query` objects.""" __slots__ = "steps", "_bakery", "_cache_key", "_spoiled" @@ -309,7 +309,7 @@ class BakedQuery(object): return query -class Result(object): +class Result: """Invokes a :class:`.BakedQuery` against a :class:`.Session`. The :class:`_baked.Result` object is where the actual :class:`.query.Query` diff --git a/lib/sqlalchemy/ext/compiler.py b/lib/sqlalchemy/ext/compiler.py index 354b0ca4a1..d961e2c815 100644 --- a/lib/sqlalchemy/ext/compiler.py +++ b/lib/sqlalchemy/ext/compiler.py @@ -416,7 +416,7 @@ def deregister(class_): del class_._compiler_dispatcher -class _dispatcher(object): +class _dispatcher: def __init__(self): self.specs = {} diff --git a/lib/sqlalchemy/ext/declarative/extensions.py b/lib/sqlalchemy/ext/declarative/extensions.py index 1a12b1205f..1862592f5c 100644 --- a/lib/sqlalchemy/ext/declarative/extensions.py +++ b/lib/sqlalchemy/ext/declarative/extensions.py @@ -37,7 +37,7 @@ def instrument_declarative(cls, cls_registry, metadata): ) -class ConcreteBase(object): +class ConcreteBase: """A helper class for 'concrete' declarative mappings. :class:`.ConcreteBase` will use the :func:`.polymorphic_union` @@ -315,7 +315,7 @@ class AbstractConcreteBase(ConcreteBase): ) -class DeferredReflection(object): +class DeferredReflection: """A helper class for construction of mappings based on a deferred reflection step. diff --git a/lib/sqlalchemy/ext/hybrid.py b/lib/sqlalchemy/ext/hybrid.py index eab3f2b738..67c42cde66 100644 --- a/lib/sqlalchemy/ext/hybrid.py +++ b/lib/sqlalchemy/ext/hybrid.py @@ -137,7 +137,7 @@ usage of the absolute value function:: from sqlalchemy import func - class Interval(object): + class Interval: # ... @hybrid_property @@ -166,7 +166,7 @@ object for class-level expressions:: the new hybrid with the additional state will be attached to the class with the non-matching name. To use the example above:: - class Interval(object): + class Interval: # ... @hybrid_property @@ -189,7 +189,7 @@ Defining Setters Hybrid properties can also define setter methods. If we wanted ``length`` above, when set, to modify the endpoint value:: - class Interval(object): + class Interval: # ... @hybrid_property @@ -231,7 +231,7 @@ accommodate a value passed to :meth:`_query.Query.update` which can affect this, using the :meth:`.hybrid_property.update_expression` decorator. A handler that works similarly to our setter would be:: - class Interval(object): + class Interval: # ... @hybrid_property @@ -267,7 +267,7 @@ above. of the hybrid must match that of how it is accessed. Something like this wouldn't work:: - class Interval(object): + class Interval: # ... def _get(self): @@ -849,7 +849,7 @@ class hybrid_method(interfaces.InspectionAttrInfo): from sqlalchemy.ext.hybrid import hybrid_method - class SomeClass(object): + class SomeClass: @hybrid_method def value(self, x, y): return self._value + x + y @@ -902,7 +902,7 @@ class hybrid_property(interfaces.InspectionAttrInfo): from sqlalchemy.ext.hybrid import hybrid_property - class SomeClass(object): + class SomeClass: @hybrid_property def value(self): return self._value @@ -958,7 +958,7 @@ class hybrid_property(interfaces.InspectionAttrInfo): to be used without conflicting with the same-named attributes normally present on the :class:`.QueryableAttribute`:: - class SuperClass(object): + class SuperClass: # ... @hybrid_property diff --git a/lib/sqlalchemy/ext/instrumentation.py b/lib/sqlalchemy/ext/instrumentation.py index 54f3e64c5d..72448fbdc8 100644 --- a/lib/sqlalchemy/ext/instrumentation.py +++ b/lib/sqlalchemy/ext/instrumentation.py @@ -193,7 +193,7 @@ orm_instrumentation._instrumentation_factory = ( orm_instrumentation.instrumentation_finders = instrumentation_finders -class InstrumentationManager(object): +class InstrumentationManager: """User-defined class instrumentation extension. :class:`.InstrumentationManager` can be subclassed in order diff --git a/lib/sqlalchemy/ext/mutable.py b/lib/sqlalchemy/ext/mutable.py index 4eed3b2afe..7e277d3799 100644 --- a/lib/sqlalchemy/ext/mutable.py +++ b/lib/sqlalchemy/ext/mutable.py @@ -113,7 +113,7 @@ mapping against the ``my_data`` table:: from sqlalchemy import mapper - class MyDataClass(object): + class MyDataClass: pass # associates mutation listeners with MyDataClass.data @@ -286,7 +286,7 @@ objects to each of the ``Vertex.start`` and ``Vertex.end`` attributes:: Column('y2', Integer), ) - class Vertex(object): + class Vertex: pass mapper(Vertex, vertices, properties={ @@ -366,7 +366,7 @@ from ..sql.base import SchemaEventTarget from ..util import memoized_property -class MutableBase(object): +class MutableBase: """Common base class to :class:`.Mutable` and :class:`.MutableComposite`. diff --git a/lib/sqlalchemy/log.py b/lib/sqlalchemy/log.py index 9ec3842a6d..2eb11750bb 100644 --- a/lib/sqlalchemy/log.py +++ b/lib/sqlalchemy/log.py @@ -57,7 +57,7 @@ def class_logger(cls): return cls -class Identified(object): +class Identified: logging_name = None def _should_log_debug(self): @@ -67,7 +67,7 @@ class Identified(object): return self.logger.isEnabledFor(logging.INFO) -class InstanceLogger(object): +class InstanceLogger: """A logger adapter (wrapper) for :class:`.Identified` subclasses. This allows multiple instances (e.g. Engine or Pool instances) @@ -204,7 +204,7 @@ def instance_logger(instance, echoflag=None): instance.logger = logger -class echo_property(object): +class echo_property: __doc__ = """\ When ``True``, enable log output for this element. diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py index 513144b872..dc58138667 100644 --- a/lib/sqlalchemy/orm/attributes.py +++ b/lib/sqlalchemy/orm/attributes.py @@ -637,7 +637,7 @@ OP_BULK_REPLACE = util.symbol("BULK_REPLACE") OP_MODIFIED = util.symbol("MODIFIED") -class AttributeEvent(object): +class AttributeEvent: """A token propagated throughout the course of a chain of attribute events. @@ -690,7 +690,7 @@ class AttributeEvent(object): Event = AttributeEvent -class AttributeImpl(object): +class AttributeImpl: """internal implementation for instrumented attributes.""" def __init__( diff --git a/lib/sqlalchemy/orm/base.py b/lib/sqlalchemy/orm/base.py index 6553cf6698..2cd4134d60 100644 --- a/lib/sqlalchemy/orm/base.py +++ b/lib/sqlalchemy/orm/base.py @@ -450,7 +450,7 @@ def class_mapper(class_, configure=True): return mapper -class InspectionAttr(object): +class InspectionAttr: """A base class applied to all ORM objects that can be returned by the :func:`_sa.inspect` function. @@ -563,7 +563,7 @@ class InspectionAttrInfo(InspectionAttr): return {} -class _MappedAttribute(object): +class _MappedAttribute: """Mixin for attributes which should be replaced by mapper-assigned attributes. diff --git a/lib/sqlalchemy/orm/clsregistry.py b/lib/sqlalchemy/orm/clsregistry.py index 4ec31bcf74..0d45fb40d4 100644 --- a/lib/sqlalchemy/orm/clsregistry.py +++ b/lib/sqlalchemy/orm/clsregistry.py @@ -118,7 +118,7 @@ def _key_is_empty(key, decl_class_registry, test): return not test(thing) -class _MultipleClassMarker(object): +class _MultipleClassMarker: """refers to multiple classes of the same name within _decl_class_registry. @@ -182,7 +182,7 @@ class _MultipleClassMarker(object): self.contents.add(weakref.ref(item, self._remove_item)) -class _ModuleMarker(object): +class _ModuleMarker: """Refers to a module name within _decl_class_registry. @@ -239,7 +239,7 @@ class _ModuleMarker(object): existing.remove_item(cls) -class _ModNS(object): +class _ModNS: __slots__ = ("__parent",) def __init__(self, parent): @@ -263,7 +263,7 @@ class _ModNS(object): ) -class _GetColumns(object): +class _GetColumns: __slots__ = ("cls",) def __init__(self, cls): @@ -297,7 +297,7 @@ inspection._inspects(_GetColumns)( ) -class _GetTable(object): +class _GetTable: __slots__ = "key", "metadata" def __init__(self, key, metadata): @@ -314,7 +314,7 @@ def _determine_container(key, value): return _GetColumns(value) -class _class_resolver(object): +class _class_resolver: __slots__ = ( "cls", "prop", diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py index f9afd4ebfe..01d77e92b7 100644 --- a/lib/sqlalchemy/orm/collections.py +++ b/lib/sqlalchemy/orm/collections.py @@ -20,7 +20,7 @@ provided. One is a bundle of generic decorators that map function arguments and return values to events:: from sqlalchemy.orm.collections import collection - class MyClass(object): + class MyClass: # ... @collection.adds(1) @@ -125,7 +125,7 @@ __all__ = [ __instrumentation_mutex = util.threading.Lock() -class _PlainColumnGetter(object): +class _PlainColumnGetter: """Plain column getter, stores collection of Column objects directly. @@ -160,7 +160,7 @@ class _PlainColumnGetter(object): return key[0] -class _SerializableColumnGetter(object): +class _SerializableColumnGetter: """Column-based getter used in version 0.7.6 only. Remains here for pickle compatibility with 0.7.6. @@ -251,7 +251,7 @@ def column_mapped_collection(mapping_spec): return lambda: MappedCollection(keyfunc) -class _SerializableAttrGetter(object): +class _SerializableAttrGetter: def __init__(self, name): self.name = name self.getter = operator.attrgetter(name) @@ -299,7 +299,7 @@ def mapped_collection(keyfunc): return lambda: MappedCollection(keyfunc) -class collection(object): +class collection: """Decorators for entity collection classes. The decorators fall into two groups: annotations and interception recipes. @@ -567,7 +567,7 @@ collection_adapter = operator.attrgetter("_sa_adapter") """Fetch the :class:`.CollectionAdapter` for a collection.""" -class CollectionAdapter(object): +class CollectionAdapter: """Bridges between the ORM and arbitrary Python collections. Proxies base-level collection operations (append, remove, iterate) diff --git a/lib/sqlalchemy/orm/context.py b/lib/sqlalchemy/orm/context.py index 0a93d993af..986daf7eb8 100644 --- a/lib/sqlalchemy/orm/context.py +++ b/lib/sqlalchemy/orm/context.py @@ -47,7 +47,7 @@ _EMPTY_DICT = util.immutabledict() LABEL_STYLE_LEGACY_ORM = util.symbol("LABEL_STYLE_LEGACY_ORM") -class QueryContext(object): +class QueryContext: __slots__ = ( "compile_state", "query", @@ -2312,7 +2312,7 @@ def _legacy_determine_last_joined_entity(setup_joins, entity_zero): return None -class _QueryEntity(object): +class _QueryEntity: """represent an entity column returned within a Query result.""" __slots__ = () diff --git a/lib/sqlalchemy/orm/decl_api.py b/lib/sqlalchemy/orm/decl_api.py index 94cda236d1..21bb9d81b2 100644 --- a/lib/sqlalchemy/orm/decl_api.py +++ b/lib/sqlalchemy/orm/decl_api.py @@ -138,7 +138,7 @@ class declared_attr(interfaces._MappedAttribute, property): easily reused across different mappings. The example below illustrates both:: - class ProvidesUser(object): + class ProvidesUser: "A mixin that adds a 'user' relationship to classes." @declared_attr @@ -271,7 +271,7 @@ class declared_attr(interfaces._MappedAttribute, property): Below, both MyClass as well as MySubClass will have a distinct ``id`` Column object established:: - class HasIdMixin(object): + class HasIdMixin: @declared_attr.cascading def id(cls): if has_inherited_table(cls): @@ -477,7 +477,7 @@ def declarative_base( ) -class registry(object): +class registry: """Generalized registry for mapping classes. The :class:`_orm.registry` serves as the basis for maintaining a collection @@ -861,7 +861,7 @@ class registry(object): mapper_registry = registry() @mapper_registry.as_declarative_base() - class Base(object): + class Base: @declared_attr def __tablename__(cls): return cls.__name__.lower() @@ -1006,7 +1006,7 @@ def as_declarative(**kw): from sqlalchemy.orm import as_declarative @as_declarative() - class Base(object): + class Base: @declared_attr def __tablename__(cls): return cls.__name__.lower() diff --git a/lib/sqlalchemy/orm/decl_base.py b/lib/sqlalchemy/orm/decl_base.py index bf1bc537da..bab890b828 100644 --- a/lib/sqlalchemy/orm/decl_base.py +++ b/lib/sqlalchemy/orm/decl_base.py @@ -151,7 +151,7 @@ def _check_declared_props_nocascade(obj, name, cls): return False -class _MapperConfig(object): +class _MapperConfig: __slots__ = ("cls", "classname", "properties", "declared_attr_reg") @classmethod diff --git a/lib/sqlalchemy/orm/dependency.py b/lib/sqlalchemy/orm/dependency.py index 27919050ec..220dc1bbb8 100644 --- a/lib/sqlalchemy/orm/dependency.py +++ b/lib/sqlalchemy/orm/dependency.py @@ -22,7 +22,7 @@ from .. import sql from .. import util -class DependencyProcessor(object): +class DependencyProcessor: def __init__(self, prop): self.prop = prop self.cascade = prop.cascade diff --git a/lib/sqlalchemy/orm/descriptor_props.py b/lib/sqlalchemy/orm/descriptor_props.py index 535067d88d..82946ca37d 100644 --- a/lib/sqlalchemy/orm/descriptor_props.py +++ b/lib/sqlalchemy/orm/descriptor_props.py @@ -37,7 +37,7 @@ class DescriptorProperty(MapperProperty): def instrument_class(self, mapper): prop = self - class _ProxyImpl(object): + class _ProxyImpl: accepts_scalar_loader = False load_on_unexpire = True collection = False @@ -523,7 +523,7 @@ class ConcreteInheritedProperty(DescriptorProperty): % (self.parent, self.key, self.parent) ) - class NoninheritedConcreteProp(object): + class NoninheritedConcreteProp: def __set__(s, obj, value): warn() @@ -595,7 +595,7 @@ class SynonymProperty(DescriptorProperty): Column('job_status', String(50)) ) - class MyClass(object): + class MyClass: @property def _job_status_descriptor(self): return "Status: %s" % self._job_status diff --git a/lib/sqlalchemy/orm/dynamic.py b/lib/sqlalchemy/orm/dynamic.py index 405498aaf6..67deb3b019 100644 --- a/lib/sqlalchemy/orm/dynamic.py +++ b/lib/sqlalchemy/orm/dynamic.py @@ -263,7 +263,7 @@ class DynamicAttributeImpl(attributes.AttributeImpl): self.remove(state, dict_, value, initiator, passive=passive) -class DynamicCollectionAdapter(object): +class DynamicCollectionAdapter: """simplified CollectionAdapter for internal API consistency""" def __init__(self, data): @@ -284,7 +284,7 @@ class DynamicCollectionAdapter(object): __nonzero__ = __bool__ -class AppenderMixin(object): +class AppenderMixin: query_class = None def __init__(self, attr, state): @@ -434,7 +434,7 @@ def mixin_user_query(cls): return type(name, (AppenderMixin, cls), {"query_class": cls}) -class CollectionHistory(object): +class CollectionHistory: """Overrides AttributeHistory to receive append/remove events directly.""" def __init__(self, attr, state, apply_to=None): diff --git a/lib/sqlalchemy/orm/evaluator.py b/lib/sqlalchemy/orm/evaluator.py index fcc7368c41..19e0be9d07 100644 --- a/lib/sqlalchemy/orm/evaluator.py +++ b/lib/sqlalchemy/orm/evaluator.py @@ -66,7 +66,7 @@ _notimplemented_ops = set( ) -class EvaluatorCompiler(object): +class EvaluatorCompiler: def __init__(self, target_cls=None): self.target_cls = target_cls diff --git a/lib/sqlalchemy/orm/events.py b/lib/sqlalchemy/orm/events.py index 2c8d155ad8..b358b8be35 100644 --- a/lib/sqlalchemy/orm/events.py +++ b/lib/sqlalchemy/orm/events.py @@ -122,7 +122,7 @@ class InstrumentationEvents(event.Events): """Called when an attribute is instrumented.""" -class _InstrumentationEventsHold(object): +class _InstrumentationEventsHold: """temporary marker object used to transfer from _accept_with() to _listen() on the InstrumentationEvents class. @@ -535,7 +535,7 @@ class _EventsHold(event.RefCollection): def _clear(cls): cls.all_holds.clear() - class HoldEvents(object): + class HoldEvents: _dispatch_target = None @classmethod diff --git a/lib/sqlalchemy/orm/identity.py b/lib/sqlalchemy/orm/identity.py index 10d924b485..917a79f91f 100644 --- a/lib/sqlalchemy/orm/identity.py +++ b/lib/sqlalchemy/orm/identity.py @@ -11,7 +11,7 @@ from . import util as orm_util from .. import exc as sa_exc -class IdentityMap(object): +class IdentityMap: def __init__(self): self._dict = {} self._modified = set() diff --git a/lib/sqlalchemy/orm/instrumentation.py b/lib/sqlalchemy/orm/instrumentation.py index 626643ce13..cb330ea17f 100644 --- a/lib/sqlalchemy/orm/instrumentation.py +++ b/lib/sqlalchemy/orm/instrumentation.py @@ -470,7 +470,7 @@ class ClassManager(HasMemoized, dict): ) -class _SerializeManager(object): +class _SerializeManager: """Provide serialization of a :class:`.ClassManager`. The :class:`.InstanceState` uses ``__init__()`` on serialize @@ -504,7 +504,7 @@ class _SerializeManager(object): manager.dispatch.unpickle(state, state_dict) -class InstrumentationFactory(object): +class InstrumentationFactory: """Factory for new ClassManager instances.""" def create_manager_for_cls(self, class_): diff --git a/lib/sqlalchemy/orm/interfaces.py b/lib/sqlalchemy/orm/interfaces.py index 9eb362c437..c425f012ba 100644 --- a/lib/sqlalchemy/orm/interfaces.py +++ b/lib/sqlalchemy/orm/interfaces.py @@ -859,7 +859,7 @@ class MapperOption(ORMOption): self.process_query(query) -class LoaderStrategy(object): +class LoaderStrategy: """Describe the loading behavior of a StrategizedProperty object. The ``LoaderStrategy`` interacts with the querying process in three diff --git a/lib/sqlalchemy/orm/loading.py b/lib/sqlalchemy/orm/loading.py index d004db0a3b..94ad7b80dd 100644 --- a/lib/sqlalchemy/orm/loading.py +++ b/lib/sqlalchemy/orm/loading.py @@ -1304,7 +1304,7 @@ def _decorate_polymorphic_switch( return polymorphic_instance -class PostLoad(object): +class PostLoad: """Track loaders and states for "post load" operations.""" __slots__ = "loaders", "states", "load_keys" diff --git a/lib/sqlalchemy/orm/query.py b/lib/sqlalchemy/orm/query.py index c987f6b166..8cf253efb0 100644 --- a/lib/sqlalchemy/orm/query.py +++ b/lib/sqlalchemy/orm/query.py @@ -3408,7 +3408,7 @@ class AliasOption(interfaces.LoaderOption): pass -class BulkUD(object): +class BulkUD: """State used for the orm.Query version of update() / delete(). This object is now specific to Query only. diff --git a/lib/sqlalchemy/orm/relationships.py b/lib/sqlalchemy/orm/relationships.py index d021ac9a29..b692daf21b 100644 --- a/lib/sqlalchemy/orm/relationships.py +++ b/lib/sqlalchemy/orm/relationships.py @@ -2604,7 +2604,7 @@ def _annotate_columns(element, annotations): return element -class JoinCondition(object): +class JoinCondition: def __init__( self, parent_persist_selectable, @@ -3677,7 +3677,7 @@ class JoinCondition(object): return lazywhere, bind_to_col, equated_columns -class _ColInAnnotations(object): +class _ColInAnnotations: """Serializable object that tests for a name in c._annotations.""" __slots__ = ("name",) diff --git a/lib/sqlalchemy/orm/scoping.py b/lib/sqlalchemy/orm/scoping.py index df3012df1e..2d04ea32c5 100644 --- a/lib/sqlalchemy/orm/scoping.py +++ b/lib/sqlalchemy/orm/scoping.py @@ -18,7 +18,7 @@ from ..util import warn_deprecated __all__ = ["scoped_session", "ScopedSessionMixin"] -class ScopedSessionMixin(object): +class ScopedSessionMixin: @property def _proxied(self): return self.registry() @@ -190,7 +190,7 @@ class scoped_session(ScopedSessionMixin): Session = scoped_session(sessionmaker()) - class MyClass(object): + class MyClass: query = Session.query_property() # after mappers are defined @@ -207,7 +207,7 @@ class scoped_session(ScopedSessionMixin): """ - class query(object): + class query: def __get__(s, instance, owner): try: mapper = class_mapper(owner) diff --git a/lib/sqlalchemy/orm/session.py b/lib/sqlalchemy/orm/session.py index 8be5fbee72..e18e358471 100644 --- a/lib/sqlalchemy/orm/session.py +++ b/lib/sqlalchemy/orm/session.py @@ -65,7 +65,7 @@ def _state_session(state): return state.session -class _SessionClassMethods(object): +class _SessionClassMethods: """Class-level methods for :class:`.Session`, :class:`.sessionmaker`.""" @classmethod diff --git a/lib/sqlalchemy/orm/state.py b/lib/sqlalchemy/orm/state.py index 994cbe53e7..0434f5f325 100644 --- a/lib/sqlalchemy/orm/state.py +++ b/lib/sqlalchemy/orm/state.py @@ -899,7 +899,7 @@ class InstanceState(interfaces.InspectionAttrInfo): state._strong_obj = None -class AttributeState(object): +class AttributeState: """Provide an inspection interface corresponding to a particular attribute on a particular mapped object. @@ -997,7 +997,7 @@ class AttributeState(object): return self.state.get_history(self.key, PASSIVE_OFF ^ INIT_OK) -class PendingCollection(object): +class PendingCollection: """A writable placeholder for an unloaded collection. Stores items appended to and removed from a collection that has not yet diff --git a/lib/sqlalchemy/orm/strategies.py b/lib/sqlalchemy/orm/strategies.py index 71c4a69761..130ff2d1eb 100644 --- a/lib/sqlalchemy/orm/strategies.py +++ b/lib/sqlalchemy/orm/strategies.py @@ -535,7 +535,7 @@ class DeferredColumnLoader(LoaderStrategy): ) -class LoadDeferredColumns(object): +class LoadDeferredColumns: """serializable loader object used by DeferredColumnLoader""" def __init__(self, key, raiseload=False): @@ -1119,7 +1119,7 @@ class LazyLoader(AbstractRelationshipLoader, util.MemoizedSlots): populators["new"].append((self.key, reset_for_lazy_callable)) -class LoadLazyAttribute(object): +class LoadLazyAttribute: """semi-serializable loader object used by LazyLoader Historically, this object would be carried along with instances that @@ -1569,7 +1569,7 @@ class SubqueryLoader(PostLoader): return q - class _SubqCollections(object): + class _SubqCollections: """Given a :class:`_query.Query` used to emit the "subquery load", provide a load interface that executes the query at the first moment a value is needed. diff --git a/lib/sqlalchemy/orm/strategy_options.py b/lib/sqlalchemy/orm/strategy_options.py index 23a8c45332..997fca1ac2 100644 --- a/lib/sqlalchemy/orm/strategy_options.py +++ b/lib/sqlalchemy/orm/strategy_options.py @@ -1186,7 +1186,7 @@ class _UnboundLoad(Load): return None -class loader_option(object): +class loader_option: def __init__(self): pass diff --git a/lib/sqlalchemy/orm/unitofwork.py b/lib/sqlalchemy/orm/unitofwork.py index f29d11bcd5..03456e5723 100644 --- a/lib/sqlalchemy/orm/unitofwork.py +++ b/lib/sqlalchemy/orm/unitofwork.py @@ -150,7 +150,7 @@ def track_cascade_events(descriptor, prop): event.listen(descriptor, "set", set_, raw=True, retval=True) -class UOWTransaction(object): +class UOWTransaction: def __init__(self, session): self.session = session @@ -477,7 +477,7 @@ class UOWTransaction(object): self.session._register_persistent(other) -class IterateMappersMixin(object): +class IterateMappersMixin: def _mappers(self, uow): if self.fromparent: return iter( @@ -539,7 +539,7 @@ class Preprocess(IterateMappersMixin): return False -class PostSortRec(object): +class PostSortRec: __slots__ = ("disabled",) def __new__(cls, uow, *args): diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py index 0e84490680..3295bd39e7 100644 --- a/lib/sqlalchemy/orm/util.py +++ b/lib/sqlalchemy/orm/util.py @@ -418,7 +418,7 @@ class ORMAdapter(sql_util.ColumnAdapter): return not entity or entity.isa(self.mapper) -class AliasedClass(object): +class AliasedClass: r"""Represents an "aliased" form of a mapped class for usage with Query. The ORM equivalent of a :func:`~sqlalchemy.sql.expression.alias` @@ -881,7 +881,7 @@ class AliasedInsp( return "aliased(%s)" % (self._target.__name__,) -class _WrapUserEntity(object): +class _WrapUserEntity: """A wrapper used within the loader_criteria lambda caller so that we can bypass declared_attr descriptors on unmapped mixins, which normally emit a warning for such use. diff --git a/lib/sqlalchemy/pool/base.py b/lib/sqlalchemy/pool/base.py index ec55da7303..1a3dcd0e46 100644 --- a/lib/sqlalchemy/pool/base.py +++ b/lib/sqlalchemy/pool/base.py @@ -25,7 +25,7 @@ reset_commit = util.symbol("reset_commit") reset_none = util.symbol("reset_none") -class _ConnDialect(object): +class _ConnDialect: """partial implementation of :class:`.Dialect` which provides DBAPI connection methods. @@ -332,7 +332,7 @@ class Pool(log.Identified): raise NotImplementedError() -class _ConnectionRecord(object): +class _ConnectionRecord: """Internal object which maintains an individual DBAPI connection referenced by a :class:`_pool.Pool`. @@ -781,7 +781,7 @@ def _finalize_fairy( _strong_ref_connection_records = {} -class _ConnectionFairy(object): +class _ConnectionFairy: """Proxies a DBAPI connection and provides return-on-dereference support. diff --git a/lib/sqlalchemy/pool/dbapi_proxy.py b/lib/sqlalchemy/pool/dbapi_proxy.py index 7dfb59e36e..e271d43fd7 100644 --- a/lib/sqlalchemy/pool/dbapi_proxy.py +++ b/lib/sqlalchemy/pool/dbapi_proxy.py @@ -61,7 +61,7 @@ def clear_managers(): proxies.clear() -class _DBProxy(object): +class _DBProxy: """Layers connection pooling behavior on top of a standard DB-API module. diff --git a/lib/sqlalchemy/sql/annotation.py b/lib/sqlalchemy/sql/annotation.py index e6618937a4..88f045fe66 100644 --- a/lib/sqlalchemy/sql/annotation.py +++ b/lib/sqlalchemy/sql/annotation.py @@ -20,7 +20,7 @@ from .. import util EMPTY_ANNOTATIONS = util.immutabledict() -class SupportsAnnotations(object): +class SupportsAnnotations: _annotations = EMPTY_ANNOTATIONS @util.memoized_property @@ -122,7 +122,7 @@ class SupportsWrappingAnnotations(SupportsAnnotations): return self -class Annotated(object): +class Annotated: """clones a SupportsAnnotated and applies an 'annotations' dictionary. Unlike regular clones, this clone also mimics __hash__() and diff --git a/lib/sqlalchemy/sql/base.py b/lib/sqlalchemy/sql/base.py index 0c375b6d77..b57da3289b 100644 --- a/lib/sqlalchemy/sql/base.py +++ b/lib/sqlalchemy/sql/base.py @@ -35,7 +35,7 @@ type_api = None NO_ARG = util.symbol("NO_ARG") -class Immutable(object): +class Immutable: """mark a ClauseElement as 'immutable' when expressions are cloned.""" _is_immutable = True @@ -276,7 +276,7 @@ def _kw_reg_for_dialect(dialect_name): return dict(dialect_cls.construct_arguments) -class DialectKWArgs(object): +class DialectKWArgs: """Establish the ability for a class to have dialect-specific arguments with defaults and constructor validation. @@ -451,7 +451,7 @@ class DialectKWArgs(object): construct_arg_dictionary[arg_name] = kwargs[k] -class CompileState(object): +class CompileState: """Produces additional object state necessary for a statement to be compiled. @@ -1056,7 +1056,7 @@ class prefix_anon_map(dict): return value -class SchemaEventTarget(object): +class SchemaEventTarget: """Base class for elements that are the targets of :class:`.DDLEvents` events. @@ -1079,7 +1079,7 @@ class SchemaVisitor(ClauseVisitor): __traverse_options__ = {"schema_visitor": True} -class ColumnCollection(object): +class ColumnCollection: """Collection of :class:`_expression.ColumnElement` instances, typically for :class:`_sql.FromClause` objects. diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index f888bad4ca..f051ba12f3 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -235,7 +235,7 @@ def expect_col_expression_collection(role, expressions): yield resolved, column, strname, add_element -class RoleImpl(object): +class RoleImpl: __slots__ = ("_role_class", "name", "_use_inspection") def _literal_coercion(self, element, **kw): @@ -282,7 +282,7 @@ class RoleImpl(object): util.raise_(exc.ArgumentError(msg, code=code), replace_context=err) -class _Deannotate(object): +class _Deannotate: __slots__ = () def _post_coercion(self, resolved, **kw): @@ -291,13 +291,13 @@ class _Deannotate(object): return _deep_deannotate(resolved) -class _StringOnly(object): +class _StringOnly: __slots__ = () _resolve_literal_only = True -class _ReturnsStringKey(object): +class _ReturnsStringKey: __slots__ = () def _implicit_coercions( @@ -312,7 +312,7 @@ class _ReturnsStringKey(object): return element -class _ColumnCoercions(object): +class _ColumnCoercions: __slots__ = () def _warn_for_scalar_subquery_coercion(self): @@ -358,7 +358,7 @@ def _no_text_coercion( ) -class _NoTextCoercion(object): +class _NoTextCoercion: __slots__ = () def _literal_coercion(self, element, argname=None, **kw): @@ -370,7 +370,7 @@ class _NoTextCoercion(object): self._raise_for_expected(element, argname) -class _CoerceLiterals(object): +class _CoerceLiterals: __slots__ = () _coerce_consts = False _coerce_star = False @@ -417,7 +417,7 @@ class LiteralValueImpl(RoleImpl): return element -class _SelectIsNotFrom(object): +class _SelectIsNotFrom: __slots__ = () def _raise_for_expected(self, element, argname=None, resolved=None, **kw): diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 191a072991..482afb42f5 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -357,7 +357,7 @@ class FromLinter(collections.namedtuple("FromLinter", ["froms", "edges"])): util.warn(message) -class Compiled(object): +class Compiled: """Represent a compiled SQL or DDL expression. @@ -4970,7 +4970,7 @@ class StrSQLTypeCompiler(GenericTypeCompiler): return get_col_spec(**kw) -class IdentifierPreparer(object): +class IdentifierPreparer: """Handle quoting and case-folding of identifiers based on options.""" diff --git a/lib/sqlalchemy/sql/dml.py b/lib/sqlalchemy/sql/dml.py index 03968d284b..e45c6b8883 100644 --- a/lib/sqlalchemy/sql/dml.py +++ b/lib/sqlalchemy/sql/dml.py @@ -1017,7 +1017,7 @@ class Insert(ValuesBase): self.select = coercions.expect(roles.DMLSelectRole, select) -class DMLWhereBase(object): +class DMLWhereBase: _where_criteria = () @_generative diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index a279f634dd..6893d99eee 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -1142,7 +1142,7 @@ class ColumnElement( return self._anon_label(label, add_hash=idx) -class WrapsColumnExpression(object): +class WrapsColumnExpression: """Mixin that defines a :class:`_expression.ColumnElement` as a wrapper with special labeling behavior for an expression that already has a name. diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py index 35b0cb7d78..31f4fab0d4 100644 --- a/lib/sqlalchemy/sql/functions.py +++ b/lib/sqlalchemy/sql/functions.py @@ -662,7 +662,7 @@ class ScalarFunctionColumn(NamedColumn): self.type = sqltypes.to_instance(type_) -class _FunctionGenerator(object): +class _FunctionGenerator: """Generate SQL function expressions. :data:`.func` is a special object instance which generates SQL diff --git a/lib/sqlalchemy/sql/lambdas.py b/lib/sqlalchemy/sql/lambdas.py index e7c19b9a03..1102607993 100644 --- a/lib/sqlalchemy/sql/lambdas.py +++ b/lib/sqlalchemy/sql/lambdas.py @@ -596,7 +596,7 @@ class LinkedLambdaElement(StatementLambdaElement): return fn(self.parent_lambda._resolved) -class AnalyzedCode(object): +class AnalyzedCode: __slots__ = ( "track_closure_variables", "track_bound_values", @@ -941,7 +941,7 @@ class AnalyzedCode(object): ) -class NonAnalyzedFunction(object): +class NonAnalyzedFunction: __slots__ = ("expr",) closure_bindparams = None @@ -955,7 +955,7 @@ class NonAnalyzedFunction(object): return self.expr -class AnalyzedFunction(object): +class AnalyzedFunction: __slots__ = ( "analyzed_code", "fn", diff --git a/lib/sqlalchemy/sql/naming.py b/lib/sqlalchemy/sql/naming.py index d01eabb588..3d86018eef 100644 --- a/lib/sqlalchemy/sql/naming.py +++ b/lib/sqlalchemy/sql/naming.py @@ -27,7 +27,7 @@ from .. import event from .. import exc -class ConventionDict(object): +class ConventionDict: def __init__(self, const, table, convention): self.const = const self._is_fk = isinstance(const, ForeignKeyConstraint) diff --git a/lib/sqlalchemy/sql/operators.py b/lib/sqlalchemy/sql/operators.py index b64bea07a0..675048cd02 100644 --- a/lib/sqlalchemy/sql/operators.py +++ b/lib/sqlalchemy/sql/operators.py @@ -33,7 +33,7 @@ from operator import truediv from .. import util -class Operators(object): +class Operators: """Base of comparison and logical operators. Implements base methods @@ -227,7 +227,7 @@ class Operators(object): raise NotImplementedError(str(op)) -class custom_op(object): +class custom_op: """Represent a 'custom' operator. :class:`.custom_op` is normally instantiated when the diff --git a/lib/sqlalchemy/sql/roles.py b/lib/sqlalchemy/sql/roles.py index 70ad4cefa7..4e009aa269 100644 --- a/lib/sqlalchemy/sql/roles.py +++ b/lib/sqlalchemy/sql/roles.py @@ -8,7 +8,7 @@ from .. import util -class SQLRole(object): +class SQLRole: """Define a "role" within a SQL statement structure. Classes within SQL Core participate within SQLRole hierarchies in order @@ -23,12 +23,12 @@ class SQLRole(object): uses_inspection = False -class UsesInspection(object): +class UsesInspection: _post_inspect = None uses_inspection = True -class AllowsLambdaRole(object): +class AllowsLambdaRole: allows_lambda = True diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index c8f26f9065..4bd49c4688 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -2639,7 +2639,7 @@ class ColumnDefault(DefaultGenerator): return "ColumnDefault(%r)" % (self.arg,) -class IdentityOptions(object): +class IdentityOptions: """Defines options for a named database sequence or an identity column. .. versionadded:: 1.3.18 @@ -3173,7 +3173,7 @@ class Constraint(DialectKWArgs, SchemaItem): raise NotImplementedError() -class ColumnCollectionMixin(object): +class ColumnCollectionMixin: columns = None """A :class:`_expression.ColumnCollection` of :class:`_schema.Column` diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 350e55c49b..a04b205b5f 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -228,7 +228,7 @@ class Selectable(ReturnsRows): ) -class HasPrefixes(object): +class HasPrefixes: _prefixes = () _has_prefixes_traverse_internals = [ @@ -284,7 +284,7 @@ class HasPrefixes(object): ) -class HasSuffixes(object): +class HasSuffixes: _suffixes = () _has_suffixes_traverse_internals = [ @@ -335,7 +335,7 @@ class HasSuffixes(object): ) -class HasHints(object): +class HasHints: _hints = util.immutabledict() _statement_hints = () @@ -1549,7 +1549,7 @@ class Join(roles.DMLTableRole, FromClause): return [self] + self.left._from_objects + self.right._from_objects -class NoInit(object): +class NoInit: def __init__(self, *arg, **kw): raise NotImplementedError( "The %s class is not intended to be constructed " @@ -3360,7 +3360,7 @@ class SelectStatementGrouping(GroupedElement, SelectBase): return self.element._from_objects -class DeprecatedSelectBaseGenerations(object): +class DeprecatedSelectBaseGenerations: """A collection of methods available on :class:`_sql.Select` and :class:`_sql.CompoundSelect`, these are all **deprecated** methods as they modify the object in-place. @@ -4214,7 +4214,7 @@ class CompoundSelect(HasCompileState, GenerativeSelect): self._bind = bind -class DeprecatedSelectGenerations(object): +class DeprecatedSelectGenerations: """A collection of methods available on :class:`_sql.Select`, these are all **deprecated** methods as they modify the :class:`_sql.Select` object in -place. @@ -4730,7 +4730,7 @@ class SelectState(util.MemoizedSlots, CompileState): return replace_from_obj_index -class _SelectFromElements(object): +class _SelectFromElements: def _iterate_from_elements(self): # note this does not include elements # in _setup_joins or _legacy_setup_joins diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 52033f5865..1687c9f29d 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -44,7 +44,7 @@ from ..util import OrderedDict from ..util import pickle -class _LookupExpressionAdapter(object): +class _LookupExpressionAdapter: """Mixin expression adaptations based on lookup tables. @@ -75,7 +75,7 @@ class _LookupExpressionAdapter(object): comparator_factory = Comparator -class Concatenable(object): +class Concatenable: """A mixin that marks a type as supporting 'concatenation', typically strings.""" @@ -95,7 +95,7 @@ class Concatenable(object): comparator_factory = Comparator -class Indexable(object): +class Indexable: """A mixin that marks a type as supporting indexing operations, such as array or JSON structures. diff --git a/lib/sqlalchemy/sql/traversals.py b/lib/sqlalchemy/sql/traversals.py index 3d377271f9..6acd794aa3 100644 --- a/lib/sqlalchemy/sql/traversals.py +++ b/lib/sqlalchemy/sql/traversals.py @@ -48,7 +48,7 @@ def _preconfigure_traversals(target_hierarchy): ) -class HasCacheKey(object): +class HasCacheKey: _cache_key_traversal = NO_CACHE __slots__ = () @@ -713,7 +713,7 @@ class _CacheKey(ExtendedInternalTraversal): _cache_key_traversal_visitor = _CacheKey() -class HasCopyInternals(object): +class HasCopyInternals: def _clone(self, **kw): raise NotImplementedError() diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index 5e929c4a95..01763f2662 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -810,7 +810,7 @@ class VisitableCheckKWArg(util.EnsureKWArgType, TraversibleType): pass -class ExternalType(object): +class ExternalType: """mixin that defines attributes and behaviors specific to third-party datatypes. @@ -1064,7 +1064,7 @@ class UserDefinedType( return self -class Emulated(object): +class Emulated: """Mixin for base types that emulate the behavior of a DB-native type. An :class:`.Emulated` type will use an available database type @@ -1111,7 +1111,7 @@ class Emulated(object): return super(Emulated, self).adapt(impltype, **kw) -class NativeForEmulated(object): +class NativeForEmulated: """Indicates DB-native types supported by an :class:`.Emulated` type. .. versionadded:: 1.2.0b3 diff --git a/lib/sqlalchemy/sql/util.py b/lib/sqlalchemy/sql/util.py index 7fcb45709f..6394c43a0e 100644 --- a/lib/sqlalchemy/sql/util.py +++ b/lib/sqlalchemy/sql/util.py @@ -461,7 +461,7 @@ def _quote_ddl_expr(element): return repr(element) -class _repr_base(object): +class _repr_base: _LIST = 0 _TUPLE = 1 _DICT = 2 @@ -969,7 +969,7 @@ class ColumnAdapter(ClauseAdapter): self.allow_label_resolve = allow_label_resolve self._wrap = None - class _IncludeExcludeMapping(object): + class _IncludeExcludeMapping: def __init__(self, parent, columns): self.parent = parent self.columns = columns diff --git a/lib/sqlalchemy/sql/visitors.py b/lib/sqlalchemy/sql/visitors.py index 7111c5efd7..82cb7a253c 100644 --- a/lib/sqlalchemy/sql/visitors.py +++ b/lib/sqlalchemy/sql/visitors.py @@ -506,7 +506,7 @@ class ExtendedInternalTraversal(InternalTraversal): HasCacheKey objects.""" -class ExternalTraversal(object): +class ExternalTraversal: """Base class for visitor objects which can traverse externally using the :func:`.visitors.traverse` function. diff --git a/lib/sqlalchemy/testing/assertions.py b/lib/sqlalchemy/testing/assertions.py index 3aa2649f45..ed634befe3 100644 --- a/lib/sqlalchemy/testing/assertions.py +++ b/lib/sqlalchemy/testing/assertions.py @@ -368,7 +368,7 @@ def _assert_raises( return ec.error -class _ErrorContainer(object): +class _ErrorContainer: error = None @@ -414,7 +414,7 @@ def expect_raises_message(except_cls, msg, check_context=True): return _expect_raises(except_cls, msg=msg, check_context=check_context) -class AssertsCompiledSQL(object): +class AssertsCompiledSQL: def assert_compile( self, clause, @@ -496,14 +496,14 @@ class AssertsCompiledSQL(object): if compile_kwargs: kw["compile_kwargs"] = compile_kwargs - class DontAccess(object): + class DontAccess: def __getattribute__(self, key): raise NotImplementedError( "compiler accessed .statement; use " "compiler.current_executable" ) - class CheckCompilerAccess(object): + class CheckCompilerAccess: def __init__(self, test_statement): self.test_statement = test_statement self._annotations = {} @@ -596,7 +596,7 @@ class AssertsCompiledSQL(object): ) -class ComparesTables(object): +class ComparesTables: def assert_tables_equal(self, table, reflected_table, strict_types=False): assert len(table.c) == len(reflected_table.c) for c, reflected_c in zip(table.c, reflected_table.c): @@ -640,7 +640,7 @@ class ComparesTables(object): ) -class AssertsExecutionResults(object): +class AssertsExecutionResults: def assert_result(self, result, class_, *objects): result = list(result) print(repr(result)) diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py index 9816c99b7f..485a13f82f 100644 --- a/lib/sqlalchemy/testing/assertsql.py +++ b/lib/sqlalchemy/testing/assertsql.py @@ -16,7 +16,7 @@ from ..engine.default import DefaultDialect from ..schema import _DDLCompiles -class AssertRule(object): +class AssertRule: is_consumed = False errormessage = None @@ -382,7 +382,7 @@ class Or(AllOf): self.errormessage = list(self.rules)[0].errormessage -class SQLExecuteObserved(object): +class SQLExecuteObserved: def __init__(self, context, clauseelement, multiparams, params): self.context = context self.clauseelement = clauseelement @@ -408,7 +408,7 @@ class SQLCursorExecuteObserved( pass -class SQLAsserter(object): +class SQLAsserter: def __init__(self): self.accumulated = [] diff --git a/lib/sqlalchemy/testing/config.py b/lib/sqlalchemy/testing/config.py index 097eb94e41..8faeea6341 100644 --- a/lib/sqlalchemy/testing/config.py +++ b/lib/sqlalchemy/testing/config.py @@ -106,7 +106,7 @@ def mark_base_test_class(): return _fixture_functions.mark_base_test_class() -class Config(object): +class Config: def __init__(self, db, db_opts, options, file_config): self._set_name(db) self.db = db diff --git a/lib/sqlalchemy/testing/engines.py b/lib/sqlalchemy/testing/engines.py index 815009e783..98de5df5c4 100644 --- a/lib/sqlalchemy/testing/engines.py +++ b/lib/sqlalchemy/testing/engines.py @@ -19,7 +19,7 @@ from .. import event from .. import pool -class ConnectionKiller(object): +class ConnectionKiller: def __init__(self): self.proxy_refs = weakref.WeakKeyDictionary() self.testing_engines = collections.defaultdict(set) @@ -202,7 +202,7 @@ def all_dialects(exclude=None): yield mod.dialect() -class ReconnectFixture(object): +class ReconnectFixture: def __init__(self, dbapi): self.dbapi = dbapi self.connections = [] @@ -362,7 +362,7 @@ def mock_engine(dialect_name=None): return engine -class DBAPIProxyCursor(object): +class DBAPIProxyCursor: """Proxy a DBAPI cursor. Tests can provide subclasses of this to intercept @@ -391,7 +391,7 @@ class DBAPIProxyCursor(object): return getattr(self.cursor, key) -class DBAPIProxyConnection(object): +class DBAPIProxyConnection: """Proxy a DBAPI connection. Tests can provide subclasses of this to intercept diff --git a/lib/sqlalchemy/testing/entities.py b/lib/sqlalchemy/testing/entities.py index 9daa5c61f8..15b6388fb4 100644 --- a/lib/sqlalchemy/testing/entities.py +++ b/lib/sqlalchemy/testing/entities.py @@ -12,7 +12,7 @@ from ..util import compat _repr_stack = set() -class BasicEntity(object): +class BasicEntity: def __init__(self, **kw): for key, value in kw.items(): setattr(self, key, value) @@ -39,7 +39,7 @@ class BasicEntity(object): _recursion_stack = set() -class ComparableMixin(object): +class ComparableMixin: def __ne__(self, other): return not self.__eq__(other) diff --git a/lib/sqlalchemy/testing/exclusions.py b/lib/sqlalchemy/testing/exclusions.py index e8fce5a4c8..7b2343128a 100644 --- a/lib/sqlalchemy/testing/exclusions.py +++ b/lib/sqlalchemy/testing/exclusions.py @@ -31,7 +31,7 @@ def fails_if(predicate, reason=None): return rule -class compound(object): +class compound: def __init__(self): self.fails = set() self.skips = set() @@ -186,7 +186,7 @@ def succeeds_if(predicate, reason=None): return fails_if(NotPredicate(predicate), reason) -class Predicate(object): +class Predicate: @classmethod def as_predicate(cls, predicate, description=None): if isinstance(predicate, compound): diff --git a/lib/sqlalchemy/testing/fixtures.py b/lib/sqlalchemy/testing/fixtures.py index 1899e5b7cb..d5e8e376a3 100644 --- a/lib/sqlalchemy/testing/fixtures.py +++ b/lib/sqlalchemy/testing/fixtures.py @@ -26,7 +26,7 @@ from ..schema import sort_tables_and_constraints @config.mark_base_test_class() -class TestBase(object): +class TestBase: # A sequence of requirement names matching testing.requires decorators __requires__ = () @@ -299,7 +299,7 @@ class TestBase(object): _connection_fixture_connection = None -class FutureEngineMixin(object): +class FutureEngineMixin: """alembic's suite still using this""" @@ -504,7 +504,7 @@ class TablesTest(TestBase): ) -class NoCache(object): +class NoCache: @config.fixture(autouse=True, scope="function") def _disable_cache(self): _cache = config.db._compiled_cache @@ -513,7 +513,7 @@ class NoCache(object): config.db._compiled_cache = _cache -class RemovesEvents(object): +class RemovesEvents: @util.memoized_property def _event_fns(self): return set() @@ -704,7 +704,7 @@ class DeclarativeMappedTest(MappedTest): cls_registry[classname] = cls DeclarativeMeta.__init__(cls, classname, bases, dict_) - class DeclarativeBasic(object): + class DeclarativeBasic: __table_cls__ = schema.Table _DeclBase = declarative_base( diff --git a/lib/sqlalchemy/testing/pickleable.py b/lib/sqlalchemy/testing/pickleable.py index 430cb5fb68..cf11ab03d6 100644 --- a/lib/sqlalchemy/testing/pickleable.py +++ b/lib/sqlalchemy/testing/pickleable.py @@ -45,13 +45,13 @@ class Parent(fixtures.ComparableEntity): pass -class Screen(object): +class Screen: def __init__(self, obj, parent=None): self.obj = obj self.parent = parent -class Foo(object): +class Foo: def __init__(self, moredata, stuff="im stuff"): self.data = "im data" self.stuff = stuff @@ -67,7 +67,7 @@ class Foo(object): ) -class Bar(object): +class Bar: def __init__(self, x, y): self.x = x self.y = y @@ -104,7 +104,7 @@ class OldSchoolWithoutCompare: self.y = y -class BarWithoutCompare(object): +class BarWithoutCompare: def __init__(self, x, y): self.x = x self.y = y @@ -113,7 +113,7 @@ class BarWithoutCompare(object): return "Bar(%d, %d)" % (self.x, self.y) -class NotComparable(object): +class NotComparable: def __init__(self, data): self.data = data @@ -127,7 +127,7 @@ class NotComparable(object): return NotImplemented -class BrokenComparable(object): +class BrokenComparable: def __init__(self, data): self.data = data diff --git a/lib/sqlalchemy/testing/plugin/plugin_base.py b/lib/sqlalchemy/testing/plugin/plugin_base.py index d2e4a0f690..b382e97f63 100644 --- a/lib/sqlalchemy/testing/plugin/plugin_base.py +++ b/lib/sqlalchemy/testing/plugin/plugin_base.py @@ -38,7 +38,7 @@ else: import ConfigParser as configparser import collections as collections_abc # noqa - class ABC(object): + class ABC: __metaclass__ = abc.ABCMeta diff --git a/lib/sqlalchemy/testing/profiling.py b/lib/sqlalchemy/testing/profiling.py index 10344c8d69..b6a6e75b17 100644 --- a/lib/sqlalchemy/testing/profiling.py +++ b/lib/sqlalchemy/testing/profiling.py @@ -55,7 +55,7 @@ def _start_current_test(id_): _profile_stats.reset_count() -class ProfileStatsFile(object): +class ProfileStatsFile: """Store per-platform/fn profiling results in a file. There was no json module available when this was written, but now diff --git a/lib/sqlalchemy/testing/provision.py b/lib/sqlalchemy/testing/provision.py index a911ba69ce..15613957c6 100644 --- a/lib/sqlalchemy/testing/provision.py +++ b/lib/sqlalchemy/testing/provision.py @@ -17,7 +17,7 @@ log = logging.getLogger(__name__) FOLLOWER_IDENT = None -class register(object): +class register: def __init__(self): self.fns = {} diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py index 43849efca0..325c0a9bb0 100644 --- a/lib/sqlalchemy/testing/requirements.py +++ b/lib/sqlalchemy/testing/requirements.py @@ -25,7 +25,7 @@ from .. import util from ..pool import QueuePool -class Requirements(object): +class Requirements: pass diff --git a/lib/sqlalchemy/testing/schema.py b/lib/sqlalchemy/testing/schema.py index 9b5546ce78..60ea5284f9 100644 --- a/lib/sqlalchemy/testing/schema.py +++ b/lib/sqlalchemy/testing/schema.py @@ -88,7 +88,7 @@ def Column(*args, **kw): return col -class eq_type_affinity(object): +class eq_type_affinity: """Helper to compare types inside of datastructures based on affinity. E.g.:: @@ -125,7 +125,7 @@ class eq_type_affinity(object): return self.target._type_affinity is not other._type_affinity -class eq_clause_element(object): +class eq_clause_element: """Helper to compare SQL structures based on compare()""" def __init__(self, target): diff --git a/lib/sqlalchemy/testing/suite/test_types.py b/lib/sqlalchemy/testing/suite/test_types.py index aa796df76c..4a5396ed82 100644 --- a/lib/sqlalchemy/testing/suite/test_types.py +++ b/lib/sqlalchemy/testing/suite/test_types.py @@ -45,7 +45,7 @@ from ...orm import Session from ...util import u -class _LiteralRoundTripFixture(object): +class _LiteralRoundTripFixture: supports_whereclause = True @testing.fixture diff --git a/lib/sqlalchemy/util/_collections.py b/lib/sqlalchemy/util/_collections.py index 54ed522d47..9efbeb7db4 100644 --- a/lib/sqlalchemy/util/_collections.py +++ b/lib/sqlalchemy/util/_collections.py @@ -24,7 +24,7 @@ from .compat import threading EMPTY_SET = frozenset() -class ImmutableContainer(object): +class ImmutableContainer: def _immutable(self, *arg, **kw): raise TypeError("%s object is immutable" % self.__class__.__name__) @@ -140,7 +140,7 @@ class FacadeDict(ImmutableContainer, dict): return "FacadeDict(%s)" % dict.__repr__(self) -class Properties(object): +class Properties: """Provide a __getattr__/__setattr__ interface over a dict.""" __slots__ = ("_data",) @@ -454,7 +454,7 @@ class OrderedSet(set): __isub__ = difference_update -class IdentitySet(object): +class IdentitySet: """A set that considers only object id() for uniqueness. This strategy has edge cases for builtin types- it's possible to have @@ -676,7 +676,7 @@ class IdentitySet(object): return "%s(%r)" % (type(self).__name__, list(self._members.values())) -class WeakSequence(object): +class WeakSequence: def __init__(self, __elements=()): # adapted from weakref.WeakKeyDictionary, prevent reference # cycles in the collection itself @@ -780,7 +780,7 @@ def unique_list(seq, hashfunc=None): ] -class UniqueAppender(object): +class UniqueAppender: """Appends items to a collection ensuring uniqueness. Additional appends() of the same object are ignored. Membership is @@ -960,7 +960,7 @@ class LRUCache(dict): self._mutex.release() -class ScopedRegistry(object): +class ScopedRegistry: """A Registry that can store one or multiple instances of a single class on the basis of a "scope" function. diff --git a/lib/sqlalchemy/util/compat.py b/lib/sqlalchemy/util/compat.py index 5749b33375..75b2a9a8df 100644 --- a/lib/sqlalchemy/util/compat.py +++ b/lib/sqlalchemy/util/compat.py @@ -47,7 +47,7 @@ FullArgSpec = collections.namedtuple( ) -class nullcontext(object): +class nullcontext: """Context manager that does no additional processing. Vendored from Python 3.7. @@ -244,7 +244,7 @@ else: from abc import ABCMeta - class ABC(object): + class ABC: __metaclass__ = ABCMeta try: diff --git a/lib/sqlalchemy/util/langhelpers.py b/lib/sqlalchemy/util/langhelpers.py index 84c5fddec9..ac2c6e6a42 100644 --- a/lib/sqlalchemy/util/langhelpers.py +++ b/lib/sqlalchemy/util/langhelpers.py @@ -35,7 +35,7 @@ def md5_hex(x): return m.hexdigest() -class safe_reraise(object): +class safe_reraise: """Reraise an exception after invoking some handler code. @@ -316,7 +316,7 @@ def %(name)s(%(args)s): return decorated -class PluginLoader(object): +class PluginLoader: def __init__(self, group, auto_fn=None): self.group = group self.impls = {} @@ -845,7 +845,7 @@ def generic_repr(obj, additional_kw=(), to_inspect=None, omit_kwarg=()): return "%s(%s)" % (obj.__class__.__name__, ", ".join(output)) -class portable_instancemethod(object): +class portable_instancemethod: """Turn an instancemethod into a (parent, name) pair to produce a serializable callable. @@ -1063,7 +1063,7 @@ def as_interface(obj, cls=None, methods=None, required=None): % (obj, qualifier, ", ".join(interface)) ) - class AnonymousInterface(object): + class AnonymousInterface: """A callable-holding shell.""" if cls: @@ -1087,7 +1087,7 @@ def as_interface(obj, cls=None, methods=None, required=None): ) -class memoized_property(object): +class memoized_property: """A read-only @property that is only evaluated once.""" def __init__(self, fget, doc=None): @@ -1132,7 +1132,7 @@ def memoized_instancemethod(fn): return update_wrapper(oneshot, fn) -class HasMemoized(object): +class HasMemoized: """A class that maintains the names of memoized elements in a collection for easy cache clearing, generative, etc. @@ -1154,7 +1154,7 @@ class HasMemoized(object): self.__dict__[key] = value self._memoized_keys |= {key} - class memoized_attribute(object): + class memoized_attribute: """A read-only @property that is only evaluated once.""" def __init__(self, fget, doc=None): @@ -1188,7 +1188,7 @@ class HasMemoized(object): return update_wrapper(oneshot, fn) -class MemoizedSlots(object): +class MemoizedSlots: """Apply memoized items to an object using a __getattr__ scheme. This allows the functionality of memoized_property and @@ -1420,7 +1420,7 @@ class classproperty(property): return desc.fget(cls) -class hybridproperty(object): +class hybridproperty: def __init__(self, func): self.func = func self.clslevel = func @@ -1437,7 +1437,7 @@ class hybridproperty(object): return self -class hybridmethod(object): +class hybridmethod: """Decorate a function as cls- or instance- level.""" def __init__(self, func): @@ -1480,7 +1480,7 @@ class _symbol(int): _symbol.__name__ = "symbol" -class symbol(object): +class symbol: """A constant symbol. >>> symbol('foo') is symbol('foo') diff --git a/test/aaa_profiling/test_memusage.py b/test/aaa_profiling/test_memusage.py index 518b215dd6..a876108a60 100644 --- a/test/aaa_profiling/test_memusage.py +++ b/test/aaa_profiling/test_memusage.py @@ -335,7 +335,7 @@ class MemUsageTest(EnsureZeroed): @testing.fails() def test_fixture_failure(self): - class Foo(object): + class Foo: pass stuff = [] @@ -356,7 +356,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): # ensure a pure growing test trips the assertion @testing.fails_if(lambda: True) def test_fixture(self): - class Foo(object): + class Foo: pass x = [] @@ -556,7 +556,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): *[Column("col%d" % i, Integer) for i in range(10)] ) - class Wide(object): + class Wide: pass self.mapper_registry.map_imperatively( @@ -604,7 +604,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): ), ) - class SomeClass(object): + class SomeClass: pass self.mapper_registry.map_imperatively(SomeClass, some_table) @@ -1021,7 +1021,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): Column("t1id", ForeignKey("t1.id")), ) - class T1(object): + class T1: pass t1_mapper = self.mapper_registry.map_imperatively(T1, t1) @@ -1029,7 +1029,7 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): @testing.emits_warning() @profile_memory() def go(): - class T2(object): + class T2: pass t2_mapper = self.mapper_registry.map_imperatively(T2, t2) @@ -1065,10 +1065,10 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): Column("t1id", Integer, ForeignKey("table1.id")), ) - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass self.mapper_registry.map_imperatively( @@ -1119,10 +1119,10 @@ class MemUsageWBackendTest(fixtures.MappedTest, EnsureZeroed): Column("t1id", Integer, ForeignKey("table1.id")), ) - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass self.mapper_registry.map_imperatively( @@ -1203,7 +1203,7 @@ class CycleTest(_fixtures.FixtureTest): users = self.tables.users - class Foo(object): + class Foo: @hybrid.hybrid_property def user_name(self): return self.name @@ -1593,7 +1593,7 @@ class CycleTest(_fixtures.FixtureTest): go() def test_weak_sequence(self): - class Foo(object): + class Foo: pass f = Foo() diff --git a/test/aaa_profiling/test_misc.py b/test/aaa_profiling/test_misc.py index 3d6700542e..4f811e69ad 100644 --- a/test/aaa_profiling/test_misc.py +++ b/test/aaa_profiling/test_misc.py @@ -20,7 +20,7 @@ class EnumTest(fixtures.TestBase): __requires__ = ("cpython", "python_profiling_backend") def setup_test(self): - class SomeEnum(object): + class SomeEnum: # Implements PEP 435 in the minimal fashion needed by SQLAlchemy _members = {} diff --git a/test/aaa_profiling/test_pool.py b/test/aaa_profiling/test_pool.py index 2b1a490c24..374fa23820 100644 --- a/test/aaa_profiling/test_pool.py +++ b/test/aaa_profiling/test_pool.py @@ -10,7 +10,7 @@ pool = None class QueuePoolTest(fixtures.TestBase, AssertsExecutionResults): __requires__ = ("cpython", "python_profiling_backend") - class Connection(object): + class Connection: def rollback(self): pass diff --git a/test/aaa_profiling/test_resultset.py b/test/aaa_profiling/test_resultset.py index 83788ce464..1f777e42e4 100644 --- a/test/aaa_profiling/test_resultset.py +++ b/test/aaa_profiling/test_resultset.py @@ -211,7 +211,7 @@ class RowTest(fixtures.TestBase): __backend__ = True def _rowproxy_fixture(self, keys, processors, row, row_cls): - class MockMeta(object): + class MockMeta: def __init__(self): pass @@ -260,7 +260,7 @@ class RowTest(fixtures.TestBase): self._test_getitem_value_refcounts_new(tuple) def test_value_refcounts_custom_seq(self): - class CustomSeq(object): + class CustomSeq: def __init__(self, data): self.data = data diff --git a/test/base/test_events.py b/test/base/test_events.py index d38f61c1ea..c94de7dd51 100644 --- a/test/base/test_events.py +++ b/test/base/test_events.py @@ -15,7 +15,7 @@ from sqlalchemy.testing.mock import Mock from sqlalchemy.testing.util import gc_collect -class TearDownLocalEventsFixture(object): +class TearDownLocalEventsFixture: def teardown_test(self): classes = set() for entry in event.base._registrars.values(): @@ -41,7 +41,7 @@ class EventsTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_three(self, x): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) self.Target = Target @@ -269,7 +269,7 @@ class EventsTest(TearDownLocalEventsFixture, fixtures.TestBase): class SlotsEventsTest(fixtures.TestBase): def test_no_slots_dispatch(self): - class Target(object): + class Target: __slots__ = () class TargetEvents(event.Events): @@ -294,7 +294,7 @@ class SlotsEventsTest(fixtures.TestBase): event.listen(t1, "event_one", Mock()) def test_slots_dispatch(self): - class Target(object): + class Target: __slots__ = ("_slots_dispatch",) class TargetEvents(event.Events): @@ -331,7 +331,7 @@ class NamedCallTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_five(self, x, y, z, q): pass - class TargetOne(object): + class TargetOne: dispatch = event.dispatcher(TargetEventsOne) return TargetOne @@ -355,7 +355,7 @@ class NamedCallTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_five(self, x, y, z, q): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) return Target @@ -453,7 +453,7 @@ class LegacySignatureTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_six(self, x, y): pass - class TargetOne(object): + class TargetOne: dispatch = event.dispatcher(TargetEventsOne) self.TargetOne = TargetOne @@ -556,7 +556,7 @@ class LegacySignatureTest(TearDownLocalEventsFixture, fixtures.TestBase): def test_legacy_accept_from_method(self): canary = Mock() - class MyClass(object): + class MyClass: def handler1(self, x, y): canary(x, y) @@ -612,7 +612,7 @@ class ClsLevelListenTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, x, y): pass - class TargetOne(object): + class TargetOne: dispatch = event.dispatcher(TargetEventsOne) self.TargetOne = TargetOne @@ -685,10 +685,10 @@ class AcceptTargetsTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, x, y): pass - class TargetOne(object): + class TargetOne: dispatch = event.dispatcher(TargetEventsOne) - class TargetTwo(object): + class TargetTwo: dispatch = event.dispatcher(TargetEventsTwo) self.TargetOne = TargetOne @@ -745,7 +745,7 @@ class CustomTargetsTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, x, y): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) self.Target = Target @@ -775,7 +775,7 @@ class SubclassGrowthTest(TearDownLocalEventsFixture, fixtures.TestBase): def some_event(self, x, y): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) self.Target = Target @@ -813,7 +813,7 @@ class ListenOverrideTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, x, y): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) self.Target = Target @@ -862,7 +862,7 @@ class PropagateTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_two(self, arg): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) self.Target = Target @@ -893,7 +893,7 @@ class JoinTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, target, arg): pass - class BaseTarget(object): + class BaseTarget: dispatch = event.dispatcher(TargetEvents) class TargetFactory(BaseTarget): @@ -1113,7 +1113,7 @@ class DisableClsPropagateTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, target, arg): pass - class BaseTarget(object): + class BaseTarget: dispatch = event.dispatcher(TargetEvents) class SubTarget(BaseTarget): @@ -1171,7 +1171,7 @@ class RemovalTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_three(self, x): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) return Target @@ -1192,7 +1192,7 @@ class RemovalTest(TearDownLocalEventsFixture, fixtures.TestBase): def event_one(self, x): pass - class Target(object): + class Target: dispatch = event.dispatcher(TargetEvents) return Target @@ -1235,7 +1235,7 @@ class RemovalTest(TearDownLocalEventsFixture, fixtures.TestBase): def test_instance(self): Target = self._fixture() - class Foo(object): + class Foo: def __init__(self): self.mock = Mock() diff --git a/test/base/test_inspect.py b/test/base/test_inspect.py index 252d0d9777..fd433ce99a 100644 --- a/test/base/test_inspect.py +++ b/test/base/test_inspect.py @@ -8,7 +8,7 @@ from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures -class TestFixture(object): +class TestFixture: pass @@ -45,7 +45,7 @@ class TestInspection(fixtures.TestBase): class SomeFoo(TestFixture): pass - class SomeFooInspect(object): + class SomeFooInspect: def __init__(self, target): self.target = target diff --git a/test/base/test_tutorials.py b/test/base/test_tutorials.py index 2393a7f913..c8c51b0b5f 100644 --- a/test/base/test_tutorials.py +++ b/test/base/test_tutorials.py @@ -14,7 +14,7 @@ class DocTest(fixtures.TestBase): def _setup_logger(self): rootlogger = logging.getLogger("sqlalchemy.engine.Engine") - class MyStream(object): + class MyStream: def write(self, string): sys.stdout.write(string) sys.stdout.flush() diff --git a/test/base/test_utils.py b/test/base/test_utils.py index 81e402d93d..8674f47796 100644 --- a/test/base/test_utils.py +++ b/test/base/test_utils.py @@ -35,7 +35,7 @@ from sqlalchemy.util import WeakSequence class WeakSequenceTest(fixtures.TestBase): @testing.requires.predictable_gc def test_cleanout_elements(self): - class Foo(object): + class Foo: pass f1, f2, f3 = Foo(), Foo(), Foo() @@ -49,7 +49,7 @@ class WeakSequenceTest(fixtures.TestBase): @testing.requires.predictable_gc def test_cleanout_appended(self): - class Foo(object): + class Foo: pass f1, f2, f3 = Foo(), Foo(), Foo() @@ -273,7 +273,7 @@ class MemoizedAttrTest(fixtures.TestBase): def test_memoized_property(self): val = [20] - class Foo(object): + class Foo: @util.memoized_property def bar(self): v = val[0] @@ -291,7 +291,7 @@ class MemoizedAttrTest(fixtures.TestBase): def test_memoized_instancemethod(self): val = [20] - class Foo(object): + class Foo: @util.memoized_instancemethod def bar(self): v = val[0] @@ -354,7 +354,7 @@ class WrapCallableTest(fixtures.TestBase): eq_(c.__doc__, None) def test_wrapping_update_wrapper_cls(self): - class MyFancyDefault(object): + class MyFancyDefault: """a fancy default""" def __call__(self): @@ -368,7 +368,7 @@ class WrapCallableTest(fixtures.TestBase): eq_(c.__doc__, "run the fancy default") def test_wrapping_update_wrapper_cls_noclsdocstring(self): - class MyFancyDefault(object): + class MyFancyDefault: def __call__(self): """run the fancy default""" return 10 @@ -379,7 +379,7 @@ class WrapCallableTest(fixtures.TestBase): eq_(c.__doc__, "run the fancy default") def test_wrapping_update_wrapper_cls_nomethdocstring(self): - class MyFancyDefault(object): + class MyFancyDefault: """a fancy default""" def __call__(self): @@ -391,7 +391,7 @@ class WrapCallableTest(fixtures.TestBase): eq_(c.__doc__, "a fancy default") def test_wrapping_update_wrapper_cls_noclsdocstring_nomethdocstring(self): - class MyFancyDefault(object): + class MyFancyDefault: def __call__(self): return 10 @@ -1144,7 +1144,7 @@ class DedupeColumnCollectionTest(ColumnCollectionCommon, fixtures.TestBase): class LRUTest(fixtures.TestBase): def test_lru(self): - class item(object): + class item: def __init__(self, id_): self.id = id_ @@ -1217,7 +1217,7 @@ class FlattenIteratorTest(fixtures.TestBase): assert list(util.flatten_iterator(iter_list)) == ["asdf", "x", "y"] -class HashOverride(object): +class HashOverride: def __init__(self, value=None): self.value = value @@ -1225,14 +1225,14 @@ class HashOverride(object): return hash(self.value) -class NoHash(object): +class NoHash: def __init__(self, value=None): self.value = value __hash__ = None -class EqOverride(object): +class EqOverride: def __init__(self, value=None): self.value = value @@ -1251,7 +1251,7 @@ class EqOverride(object): return True -class HashEqOverride(object): +class HashEqOverride: def __init__(self, value=None): self.value = value @@ -1881,21 +1881,21 @@ class DictlikeIteritemsTest(fixtures.TestBase): self._notok(object()) def test_duck_2(self): - class duck2(object): + class duck2: def items(duck): return list(self.baseline) self._ok(duck2()) def test_duck_4(self): - class duck4(object): + class duck4: def iterkeys(duck): return iter(["a", "b", "c"]) self._notok(duck4()) def test_duck_5(self): - class duck5(object): + class duck5: def keys(duck): return ["a", "b", "c"] @@ -1905,7 +1905,7 @@ class DictlikeIteritemsTest(fixtures.TestBase): self._ok(duck5()) def test_duck_6(self): - class duck6(object): + class duck6: def keys(duck): return ["a", "b", "c"] @@ -1914,7 +1914,7 @@ class DictlikeIteritemsTest(fixtures.TestBase): class DuckTypeCollectionTest(fixtures.TestBase): def test_sets(self): - class SetLike(object): + class SetLike: def add(self): pass @@ -1934,7 +1934,7 @@ class DuckTypeCollectionTest(fixtures.TestBase): class PublicFactoryTest(fixtures.TestBase): def _fixture(self): - class Thingy(object): + class Thingy: def __init__(self, value): "make a thingy" self.value = value @@ -1969,7 +1969,7 @@ class PublicFactoryTest(fixtures.TestBase): class ArgInspectionTest(fixtures.TestBase): def test_get_cls_kwargs(self): - class A(object): + class A: def __init__(self, a): pass @@ -1981,7 +1981,7 @@ class ArgInspectionTest(fixtures.TestBase): def __init__(self, a11, **kw): pass - class B(object): + class B: def __init__(self, b, **kw): pass @@ -2022,7 +2022,7 @@ class ArgInspectionTest(fixtures.TestBase): class CB2A(B2, A): pass - class D(object): + class D: pass class BA2(B, A): @@ -2113,7 +2113,7 @@ class ArgInspectionTest(fixtures.TestBase): assert_raises(TypeError, get_callable_argspec, object) def test_callable_argspec_method(self): - class Foo(object): + class Foo: def foo(self, x, y, **kw): pass @@ -2125,7 +2125,7 @@ class ArgInspectionTest(fixtures.TestBase): ) def test_callable_argspec_instance_method_no_self(self): - class Foo(object): + class Foo: def foo(self, x, y, **kw): pass @@ -2135,7 +2135,7 @@ class ArgInspectionTest(fixtures.TestBase): ) def test_callable_argspec_unbound_method_no_self(self): - class Foo(object): + class Foo: def foo(self, x, y, **kw): pass @@ -2147,7 +2147,7 @@ class ArgInspectionTest(fixtures.TestBase): ) def test_callable_argspec_init(self): - class Foo(object): + class Foo: def __init__(self, x, y): pass @@ -2159,7 +2159,7 @@ class ArgInspectionTest(fixtures.TestBase): ) def test_callable_argspec_init_no_self(self): - class Foo(object): + class Foo: def __init__(self, x, y): pass @@ -2169,7 +2169,7 @@ class ArgInspectionTest(fixtures.TestBase): ) def test_callable_argspec_call(self): - class Foo(object): + class Foo: def __call__(self, x, y): pass @@ -2181,7 +2181,7 @@ class ArgInspectionTest(fixtures.TestBase): ) def test_callable_argspec_call_no_self(self): - class Foo(object): + class Foo: def __call__(self, x, y): pass @@ -2335,7 +2335,7 @@ class SymbolTest(fixtures.TestBase): ) -class _Py3KFixtures(object): +class _Py3KFixtures: def _kw_only_fixture(self): pass @@ -2647,18 +2647,18 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): parsed = util.format_argspec_init(fn, grouped=grouped) eq_(parsed, wanted) - class Obj(object): + class Obj: pass test(Obj.__init__, object_spec) - class Obj(object): + class Obj: def __init__(self): pass test(Obj.__init__, object_spec) - class Obj(object): + class Obj: def __init__(slef, a=123): pass @@ -2690,7 +2690,7 @@ class TestFormatArgspec(_Py3KFixtures, fixtures.TestBase): class GenericReprTest(fixtures.TestBase): def test_all_positional(self): - class Foo(object): + class Foo: def __init__(self, a, b, c): self.a = a self.b = b @@ -2699,7 +2699,7 @@ class GenericReprTest(fixtures.TestBase): eq_(util.generic_repr(Foo(1, 2, 3)), "Foo(1, 2, 3)") def test_positional_plus_kw(self): - class Foo(object): + class Foo: def __init__(self, a, b, c=5, d=4): self.a = a self.b = b @@ -2709,7 +2709,7 @@ class GenericReprTest(fixtures.TestBase): eq_(util.generic_repr(Foo(1, 2, 3, 6)), "Foo(1, 2, c=3, d=6)") def test_kw_defaults(self): - class Foo(object): + class Foo: def __init__(self, a=1, b=2, c=3, d=4): self.a = a self.b = b @@ -2719,7 +2719,7 @@ class GenericReprTest(fixtures.TestBase): eq_(util.generic_repr(Foo(1, 5, 3, 7)), "Foo(b=5, d=7)") def test_multi_kw(self): - class Foo(object): + class Foo: def __init__(self, a, b, c=3, d=4): self.a = a self.b = b @@ -2746,7 +2746,7 @@ class GenericReprTest(fixtures.TestBase): ) def test_multi_kw_repeated(self): - class Foo(object): + class Foo: def __init__(self, a=1, b=2): self.a = a self.b = b @@ -2762,7 +2762,7 @@ class GenericReprTest(fixtures.TestBase): ) def test_discard_vargs(self): - class Foo(object): + class Foo: def __init__(self, a, b, *args): self.a = a self.b = b @@ -2771,7 +2771,7 @@ class GenericReprTest(fixtures.TestBase): eq_(util.generic_repr(Foo(1, 2, 3, 4)), "Foo(1, 2)") def test_discard_vargs_kwargs(self): - class Foo(object): + class Foo: def __init__(self, a, b, *args, **kw): self.a = a self.b = b @@ -2780,7 +2780,7 @@ class GenericReprTest(fixtures.TestBase): eq_(util.generic_repr(Foo(1, 2, 3, 4, x=7, y=4)), "Foo(1, 2)") def test_significant_vargs(self): - class Foo(object): + class Foo: def __init__(self, a, b, *args): self.a = a self.b = b @@ -2789,21 +2789,21 @@ class GenericReprTest(fixtures.TestBase): eq_(util.generic_repr(Foo(1, 2, 3, 4)), "Foo(1, 2, 3, 4)") def test_no_args(self): - class Foo(object): + class Foo: def __init__(self): pass eq_(util.generic_repr(Foo()), "Foo()") def test_no_init(self): - class Foo(object): + class Foo: pass eq_(util.generic_repr(Foo()), "Foo()") class AsInterfaceTest(fixtures.TestBase): - class Something(object): + class Something: def _ignoreme(self): pass @@ -2813,11 +2813,11 @@ class AsInterfaceTest(fixtures.TestBase): def bar(self): pass - class Partial(object): + class Partial: def bar(self): pass - class Object(object): + class Object: pass def test_no_cls_no_methods(self): @@ -2931,10 +2931,10 @@ class TestClassHierarchy(fixtures.TestBase): eq_(set(util.class_hierarchy(object)), set((object,))) def test_single(self): - class A(object): + class A: pass - class B(object): + class B: pass eq_(set(util.class_hierarchy(A)), set((A, object))) @@ -3009,7 +3009,7 @@ class ReraiseTest(fixtures.TestBase): class TestClassProperty(fixtures.TestBase): def test_simple(self): - class A(object): + class A: something = {"foo": 1} class B(A): @@ -3269,7 +3269,7 @@ class TestModuleRegistry(fixtures.TestBase): class MethodOveriddenTest(fixtures.TestBase): def test_subclass_overrides_cls_given(self): - class Foo(object): + class Foo: def bar(self): pass @@ -3280,7 +3280,7 @@ class MethodOveriddenTest(fixtures.TestBase): is_true(util.method_is_overridden(Bar, Foo.bar)) def test_subclass_overrides(self): - class Foo(object): + class Foo: def bar(self): pass @@ -3291,7 +3291,7 @@ class MethodOveriddenTest(fixtures.TestBase): is_true(util.method_is_overridden(Bar(), Foo.bar)) def test_subclass_overrides_skiplevel(self): - class Foo(object): + class Foo: def bar(self): pass @@ -3305,7 +3305,7 @@ class MethodOveriddenTest(fixtures.TestBase): is_true(util.method_is_overridden(Bat(), Foo.bar)) def test_subclass_overrides_twolevels(self): - class Foo(object): + class Foo: def bar(self): pass @@ -3319,7 +3319,7 @@ class MethodOveriddenTest(fixtures.TestBase): is_true(util.method_is_overridden(Bat(), Foo.bar)) def test_subclass_doesnt_override_cls_given(self): - class Foo(object): + class Foo: def bar(self): pass @@ -3329,7 +3329,7 @@ class MethodOveriddenTest(fixtures.TestBase): is_false(util.method_is_overridden(Bar, Foo.bar)) def test_subclass_doesnt_override(self): - class Foo(object): + class Foo: def bar(self): pass @@ -3339,10 +3339,10 @@ class MethodOveriddenTest(fixtures.TestBase): is_false(util.method_is_overridden(Bar(), Foo.bar)) def test_subclass_overrides_multi_mro(self): - class Base(object): + class Base: pass - class Foo(object): + class Foo: pass class Bat(Base): diff --git a/test/dialect/mssql/test_query.py b/test/dialect/mssql/test_query.py index 63b2551cd5..3576a9fc2a 100644 --- a/test/dialect/mssql/test_query.py +++ b/test/dialect/mssql/test_query.py @@ -373,7 +373,7 @@ class QueryTest(testing.AssertsExecutionResults, fixtures.TestBase): eq_(connection.scalar(table.select()), 7) -class Foo(object): +class Foo: def __init__(self, **kw): for k in kw: setattr(self, k, kw[k]) diff --git a/test/dialect/mysql/test_types.py b/test/dialect/mysql/test_types.py index 7bdf6f8ceb..c83de7f49e 100644 --- a/test/dialect/mysql/test_types.py +++ b/test/dialect/mysql/test_types.py @@ -778,7 +778,7 @@ class EnumSetTest( __dialect__ = mysql.dialect() __backend__ = True - class SomeEnum(object): + class SomeEnum: # Implements PEP 435 in the minimal fashion needed by SQLAlchemy __members__ = OrderedDict() diff --git a/test/dialect/oracle/test_types.py b/test/dialect/oracle/test_types.py index cbbb7be7c9..7034720559 100644 --- a/test/dialect/oracle/test_types.py +++ b/test/dialect/oracle/test_types.py @@ -64,7 +64,7 @@ class DialectTypesTest(fixtures.TestBase, AssertsCompiledSQL): from setting up cx_oracle.CLOBs on string-based bind params [ticket:793].""" - class FakeDBAPI(object): + class FakeDBAPI: def __getattr__(self, attr): return attr @@ -1190,7 +1190,7 @@ class SetInputSizesTest(fixtures.TestBase): ) t3 = Table("t3", m, Column("foo", TestTypeDec())) - class CursorWrapper(object): + class CursorWrapper: # cx_oracle cursor can't be modified so we have to # invent a whole wrapping scheme diff --git a/test/dialect/postgresql/test_compiler.py b/test/dialect/postgresql/test_compiler.py index 46adc62e52..93513c39db 100644 --- a/test/dialect/postgresql/test_compiler.py +++ b/test/dialect/postgresql/test_compiler.py @@ -2799,7 +2799,7 @@ class DistinctOnTest(fixtures.MappedTest, AssertsCompiledSQL): def test_query_on_columns_subquery(self): sess = Session() - class Foo(object): + class Foo: pass clear_mappers() @@ -2817,7 +2817,7 @@ class DistinctOnTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_query_distinct_on_aliased(self): - class Foo(object): + class Foo: pass self.mapper_registry.map_imperatively(Foo, self.table) diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py index 47a4728b43..7d4ea2ced1 100644 --- a/test/dialect/postgresql/test_dialect.py +++ b/test/dialect/postgresql/test_dialect.py @@ -278,7 +278,7 @@ class PGCodeTest(fixtures.TestBase): eq_(errmsg.orig.sqlstate, "23505") -class ExecuteManyMode(object): +class ExecuteManyMode: __only_on__ = "postgresql+psycopg2" __backend__ = True diff --git a/test/dialect/postgresql/test_on_conflict.py b/test/dialect/postgresql/test_on_conflict.py index 508f691c51..8adc91a17d 100644 --- a/test/dialect/postgresql/test_on_conflict.py +++ b/test/dialect/postgresql/test_on_conflict.py @@ -281,7 +281,7 @@ class OnConflictTest(fixtures.TablesTest): def test_on_conflict_do_update_clauseelem_as_key_set(self, connection): users = self.tables.users - class MyElem(object): + class MyElem: def __init__(self, expr): self.expr = expr diff --git a/test/dialect/postgresql/test_reflection.py b/test/dialect/postgresql/test_reflection.py index fa90ec212f..2bfce557fe 100644 --- a/test/dialect/postgresql/test_reflection.py +++ b/test/dialect/postgresql/test_reflection.py @@ -40,7 +40,7 @@ from sqlalchemy.testing.assertions import is_ from sqlalchemy.testing.assertions import is_true -class ReflectionFixtures(object): +class ReflectionFixtures: @testing.fixture( params=[ ("engine", True), @@ -1773,7 +1773,7 @@ class ReflectionTest( class CustomTypeReflectionTest(fixtures.TestBase): - class CustomType(object): + class CustomType: def __init__(self, arg1=None, arg2=None): self.arg1 = arg1 self.arg2 = arg2 diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 473e144550..4c0b91f93d 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -1437,7 +1437,7 @@ AnEnum("Bar", 2) AnEnum("Baz", 3) -class ArrayRoundTripTest(object): +class ArrayRoundTripTest: __only_on__ = "postgresql" __backend__ = True @@ -3189,7 +3189,7 @@ class HStoreRoundTripTest(fixtures.TablesTest): self._assert_data([{r"key \"foo\"": r'value \"bar"\ xyz'}], connection) def test_orm_round_trip(self, registry): - class Data(object): + class Data: def __init__(self, name, data): self.name = name self.data = data @@ -3446,7 +3446,7 @@ class _RangeTypeRoundTrip(fixtures.TablesTest): eq_(data, [(self._data_obj().__class__(empty=True),)]) -class _Int4RangeTests(object): +class _Int4RangeTests: _col_type = INT4RANGE _col_str = "INT4RANGE" @@ -3458,7 +3458,7 @@ class _Int4RangeTests(object): return self.extras().NumericRange(1, 2) -class _Int8RangeTests(object): +class _Int8RangeTests: _col_type = INT8RANGE _col_str = "INT8RANGE" @@ -3472,7 +3472,7 @@ class _Int8RangeTests(object): ) -class _NumRangeTests(object): +class _NumRangeTests: _col_type = NUMRANGE _col_str = "NUMRANGE" @@ -3486,7 +3486,7 @@ class _NumRangeTests(object): ) -class _DateRangeTests(object): +class _DateRangeTests: _col_type = DATERANGE _col_str = "DATERANGE" @@ -3500,7 +3500,7 @@ class _DateRangeTests(object): ) -class _DateTimeRangeTests(object): +class _DateTimeRangeTests: _col_type = TSRANGE _col_str = "TSRANGE" @@ -3515,7 +3515,7 @@ class _DateTimeRangeTests(object): ) -class _DateTimeTZRangeTests(object): +class _DateTimeTZRangeTests: _col_type = TSTZRANGE _col_str = "TSTZRANGE" diff --git a/test/dialect/test_sqlite.py b/test/dialect/test_sqlite.py index ca203ad8cb..f827533d48 100644 --- a/test/dialect/test_sqlite.py +++ b/test/dialect/test_sqlite.py @@ -2962,7 +2962,7 @@ class OnConflictTest(fixtures.TablesTest): def test_on_conflict_do_update_clauseelem_keys(self, connection): users = self.tables.users - class MyElem(object): + class MyElem: def __init__(self, expr): self.expr = expr diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py index 3ca763c320..e1c86444d5 100644 --- a/test/engine/test_execute.py +++ b/test/engine/test_execute.py @@ -60,7 +60,7 @@ class SomeException(Exception): pass -class Foo(object): +class Foo: def __str__(self): return "foo" diff --git a/test/engine/test_pool.py b/test/engine/test_pool.py index 1c730334aa..b1a099d31f 100644 --- a/test/engine/test_pool.py +++ b/test/engine/test_pool.py @@ -384,7 +384,7 @@ class PoolDialectTest(PoolTestBase): def _dialect(self): canary = [] - class PoolDialect(object): + class PoolDialect: is_async = False def do_rollback(self, dbapi_connection): diff --git a/test/engine/test_transaction.py b/test/engine/test_transaction.py index e18f1c446a..e3be847e8a 100644 --- a/test/engine/test_transaction.py +++ b/test/engine/test_transaction.py @@ -1560,7 +1560,7 @@ class ConnectionCharacteristicTest(fixtures.TestBase): ) -class ResetFixture(object): +class ResetFixture: @testing.fixture() def reset_agent(self, testing_engine): engine = testing_engine() diff --git a/test/ext/declarative/test_deprecations.py b/test/ext/declarative/test_deprecations.py index 130c127389..58ad2fced6 100644 --- a/test/ext/declarative/test_deprecations.py +++ b/test/ext/declarative/test_deprecations.py @@ -13,7 +13,7 @@ from sqlalchemy.testing import is_true class TestInstrumentDeclarative(fixtures.TestBase): def test_ok(self): - class Foo(object): + class Foo: __tablename__ = "foo" id = sa.Column(sa.Integer, primary_key=True) @@ -50,7 +50,7 @@ class DeprecatedImportsTest(fixtures.TestBase): with self._expect_warning("as_declarative"): @legacy_decl.as_declarative() - class Base(object): + class Base: pass class Foo(Base): @@ -61,7 +61,7 @@ class DeprecatedImportsTest(fixtures.TestBase): def test_has_inherited_table(self, registry): @registry.mapped - class Foo(object): + class Foo: __tablename__ = "foo" id = sa.Column(sa.Integer, primary_key=True) @@ -80,7 +80,7 @@ class DeprecatedImportsTest(fixtures.TestBase): with self._expect_warning("synonym_for"): @registry.mapped - class Foo(object): + class Foo: __tablename__ = "foo" id = sa.Column(sa.Integer, primary_key=True) diff --git a/test/ext/mypy/files/as_declarative.py b/test/ext/mypy/files/as_declarative.py index ee2f258cbe..08f08f913c 100644 --- a/test/ext/mypy/files/as_declarative.py +++ b/test/ext/mypy/files/as_declarative.py @@ -11,7 +11,7 @@ from sqlalchemy.sql.schema import ForeignKey @as_declarative() -class Base(object): +class Base: updated_at = Column(Integer) diff --git a/test/ext/mypy/files/as_declarative_base.py b/test/ext/mypy/files/as_declarative_base.py index efba8c362a..ba62e7276c 100644 --- a/test/ext/mypy/files/as_declarative_base.py +++ b/test/ext/mypy/files/as_declarative_base.py @@ -7,7 +7,7 @@ reg: registry = registry() @reg.as_declarative_base() -class Base(object): +class Base: updated_at = Column(Integer) diff --git a/test/ext/mypy/incremental/stubs_14/__init__.py b/test/ext/mypy/incremental/stubs_14/__init__.py index c40dd273ab..31696458ee 100644 --- a/test/ext/mypy/incremental/stubs_14/__init__.py +++ b/test/ext/mypy/incremental/stubs_14/__init__.py @@ -13,7 +13,7 @@ if TYPE_CHECKING: @as_declarative() -class Base(object): +class Base: @declared_attr def __tablename__(self) -> Mapped[str]: return self.__name__.lower() diff --git a/test/ext/test_associationproxy.py b/test/ext/test_associationproxy.py index 0b05fe0387..ae5e6c8483 100644 --- a/test/ext/test_associationproxy.py +++ b/test/ext/test_associationproxy.py @@ -60,7 +60,7 @@ class ListCollection(list): pass -class ObjectCollection(object): +class ObjectCollection: def __init__(self): self.values = list() @@ -103,14 +103,14 @@ class AutoFlushTest(fixtures.MappedTest): ) def _fixture(self, collection_class, is_dict=False): - class Parent(object): + class Parent: collection = association_proxy("_collection", "child") - class Child(object): + class Child: def __init__(self, name): self.name = name - class Association(object): + class Association: if is_dict: def __init__(self, key, child): @@ -974,7 +974,7 @@ class ScalarTest(fixtures.MappedTest): Column("baz", String(128)), ) - class Parent(object): + class Parent: foo = association_proxy("child", "foo") bar = association_proxy( "child", "bar", creator=lambda v: Child(bar=v) @@ -986,7 +986,7 @@ class ScalarTest(fixtures.MappedTest): def __init__(self, name): self.name = name - class Child(object): + class Child: def __init__(self, **kw): for attr in kw: setattr(self, attr, kw[attr]) @@ -1095,14 +1095,14 @@ class ScalarTest(fixtures.MappedTest): Column("name", String(50)), ) - class A(object): + class A: a2b_name = association_proxy("a2b_single", "name") b_single = association_proxy("a2b_single", "b") - class A2B(object): + class A2B: pass - class B(object): + class B: pass self.mapper_registry.map_imperatively( @@ -1136,12 +1136,12 @@ class ScalarTest(fixtures.MappedTest): get = Mock() set_ = Mock() - class Parent(object): + class Parent: foo = association_proxy( "child", "foo", getset_factory=lambda cc, parent: (get, set_) ) - class Child(object): + class Child: def __init__(self, foo): self.foo = foo @@ -1319,17 +1319,17 @@ class LazyLoadTest(fixtures.MappedTest): self.assert_(p._children is not None) -class Parent(object): +class Parent: def __init__(self, name): self.name = name -class Child(object): +class Child: def __init__(self, name): self.name = name -class KVChild(object): +class KVChild: def __init__(self, name, value): self.name = name self.value = value @@ -1461,7 +1461,7 @@ class ReconstitutionTest(fixtures.MappedTest): # assert r2 == {'c1': 'c1', 'c2': 'c2'} -class PickleKeyFunc(object): +class PickleKeyFunc: def __init__(self, name): self.name = name @@ -2483,7 +2483,7 @@ class AttributeAccessTest(fixtures.TestBase): Base = declarative_base() - class Mixin(object): + class Mixin: @declared_attr def children(cls): return association_proxy("_children", "value") @@ -2620,7 +2620,7 @@ class AttributeAccessTest(fixtures.TestBase): def test_resolved_to_correct_class_five(self): Base = declarative_base() - class Mixin(object): + class Mixin: children = association_proxy("_children", "value") class Parent(Mixin, Base): @@ -2650,7 +2650,7 @@ class AttributeAccessTest(fixtures.TestBase): foo._calc_owner(None, None) is_(foo.owning_class, None) - class Bat(object): + class Bat: foo = association_proxy("x", "y") Bat.foo @@ -2677,7 +2677,7 @@ class AttributeAccessTest(fixtures.TestBase): is_(Bat.foo.owning_class, Bat) -class ScalarRemoveTest(object): +class ScalarRemoveTest: useobject = None cascade_scalar_deletes = None uselist = None @@ -2938,7 +2938,7 @@ class InfoTest(fixtures.TestBase): eq_(assoc.info, {}) def test_via_cls(self): - class Foob(object): + class Foob: assoc = association_proxy("a", "b") eq_(Foob.assoc.info, {}) diff --git a/test/ext/test_baked.py b/test/ext/test_baked.py index 977fb36390..c40ee33955 100644 --- a/test/ext/test_baked.py +++ b/test/ext/test_baked.py @@ -292,7 +292,7 @@ class LikeQueryTest(BakedTest): def test_get_pk_w_null(self): """test the re-implementation of logic to do get with IS NULL.""" - class AddressUser(object): + class AddressUser: pass self.mapper_registry.map_imperatively( diff --git a/test/ext/test_extendedattr.py b/test/ext/test_extendedattr.py index c762754bc5..43443b7f64 100644 --- a/test/ext/test_extendedattr.py +++ b/test/ext/test_extendedattr.py @@ -35,7 +35,7 @@ def modifies_instrumentation_finders(fn, *args, **kw): instrumentation.instrumentation_finders.extend(pristine) -class _ExtBase(object): +class _ExtBase: @classmethod def teardown_test_class(cls): instrumentation._reinstall_default_lookups() @@ -107,7 +107,7 @@ class DisposeTest(_ExtBase, fixtures.TestBase): return get - class MyClass(object): + class MyClass: __sa_instrumentation_manager__ = MyClassState assert attributes.manager_of_class(MyClass) is None @@ -139,12 +139,12 @@ class UserDefinedExtensionTest(_ExtBase, fixtures.ORMTest): def setup_test_class(cls): global MyBaseClass, MyClass - class MyBaseClass(object): + class MyBaseClass: __sa_instrumentation_manager__ = ( instrumentation.InstrumentationManager ) - class MyClass(object): + class MyClass: # This proves that a staticmethod will work here; don't # flatten this back to a class assignment! @@ -523,7 +523,7 @@ class UserDefinedExtensionTest(_ExtBase, fixtures.ORMTest): def test_alternate_finders(self): """Ensure the generic finder front-end deals with edge cases.""" - class Unknown(object): + class Unknown: pass class Known(MyBaseClass): @@ -569,7 +569,7 @@ class UserDefinedExtensionTest(_ExtBase, fixtures.ORMTest): class FinderTest(_ExtBase, fixtures.ORMTest): def test_standard(self): - class A(object): + class A: pass register_class(A) @@ -577,7 +577,7 @@ class FinderTest(_ExtBase, fixtures.ORMTest): eq_(type(manager_of_class(A)), instrumentation.ClassManager) def test_nativeext_interfaceexact(self): - class A(object): + class A: __sa_instrumentation_manager__ = ( instrumentation.InstrumentationManager ) @@ -589,7 +589,7 @@ class FinderTest(_ExtBase, fixtures.ORMTest): class Mine(instrumentation.ClassManager): pass - class A(object): + class A: __sa_instrumentation_manager__ = Mine register_class(A) @@ -600,7 +600,7 @@ class FinderTest(_ExtBase, fixtures.ORMTest): class Mine(instrumentation.ClassManager): pass - class A(object): + class A: pass def find(cls): @@ -612,7 +612,7 @@ class FinderTest(_ExtBase, fixtures.ORMTest): @modifies_instrumentation_finders def test_customfinder_pass(self): - class A(object): + class A: pass def find(cls): @@ -626,7 +626,7 @@ class FinderTest(_ExtBase, fixtures.ORMTest): class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): def test_none(self): - class A(object): + class A: pass register_class(A) @@ -634,18 +634,18 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): def mgr_factory(cls): return instrumentation.ClassManager(cls) - class B(object): + class B: __sa_instrumentation_manager__ = staticmethod(mgr_factory) register_class(B) - class C(object): + class C: __sa_instrumentation_manager__ = instrumentation.ClassManager register_class(C) def test_single_down(self): - class A(object): + class A: pass register_class(A) @@ -664,7 +664,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): ) def test_single_up(self): - class A(object): + class A: pass # delay registration @@ -688,7 +688,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): def mgr_factory(cls): return instrumentation.ClassManager(cls) - class A(object): + class A: pass class B1(A): @@ -697,7 +697,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): class B2(A): __sa_instrumentation_manager__ = staticmethod(mgr_factory) - class C(object): + class C: pass assert_raises_message( @@ -711,7 +711,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): def mgr_factory(cls): return instrumentation.ClassManager(cls) - class A(object): + class A: pass class B1(A): @@ -720,7 +720,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): class B2(A): __sa_instrumentation_manager__ = staticmethod(mgr_factory) - class C(object): + class C: pass register_class(B2) @@ -735,7 +735,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): def mgr_factory(cls): return instrumentation.ClassManager(cls) - class A(object): + class A: pass class B1(A): @@ -744,7 +744,7 @@ class InstrumentationCollisionTest(_ExtBase, fixtures.ORMTest): class B2(A): __sa_instrumentation_manager__ = staticmethod(mgr_factory) - class C(object): + class C: pass register_class(C) @@ -773,7 +773,7 @@ class ExtendedEventsTest(_ExtBase, fixtures.ORMTest): 0, lambda cls: MyClassManager ) - class A(object): + class A: pass register_class(A) diff --git a/test/ext/test_horizontal_shard.py b/test/ext/test_horizontal_shard.py index edc2711b6f..e25e8c8ab9 100644 --- a/test/ext/test_horizontal_shard.py +++ b/test/ext/test_horizontal_shard.py @@ -35,7 +35,7 @@ from sqlalchemy.testing.engines import testing_engine from sqlalchemy.testing.engines import testing_reaper -class ShardTest(object): +class ShardTest: __skip_if__ = (lambda: util.win32,) __requires__ = ("sqlite",) @@ -152,12 +152,12 @@ class ShardTest(object): def setup_mappers(cls): global WeatherLocation, Report - class WeatherLocation(object): + class WeatherLocation: def __init__(self, continent, city): self.continent = continent self.city = city - class Report(object): + class Report: def __init__(self, temperature, id_=None): self.temperature = temperature if id_: diff --git a/test/ext/test_hybrid.py b/test/ext/test_hybrid.py index ad8d92b9b3..f7524808fc 100644 --- a/test/ext/test_hybrid.py +++ b/test/ext/test_hybrid.py @@ -137,7 +137,7 @@ class PropertyComparatorTest(fixtures.TestBase, AssertsCompiledSQL): """test :ticket:`6215`""" Base = declarative_base() - class SomeMixin(object): + class SomeMixin: @hybrid.hybrid_property def same_name(self): return self.id @@ -1163,7 +1163,7 @@ class SpecialObjectTest(fixtures.TestBase, AssertsCompiledSQL): for currency_from, rate in zip(symbols, values) ) - class Amount(object): + class Amount: def __init__(self, amount, currency): self.currency = currency self.amount = amount diff --git a/test/ext/test_mutable.py b/test/ext/test_mutable.py index 1d88deb7a0..6545d45458 100644 --- a/test/ext/test_mutable.py +++ b/test/ext/test_mutable.py @@ -41,7 +41,7 @@ class SubFoo(Foo): pass -class FooWithEq(object): +class FooWithEq: def __init__(self, **kw): for k in kw: setattr(self, k, kw[k]) @@ -91,7 +91,7 @@ class MyPoint(Point): return value -class _MutableDictTestFixture(object): +class _MutableDictTestFixture: @classmethod def _type_fixture(cls): return MutableDict @@ -312,7 +312,7 @@ class _MutableDictTestBase(_MutableDictTestFixture): eq_(f1.data, {"a": "b"}) -class _MutableListTestFixture(object): +class _MutableListTestFixture: @classmethod def _type_fixture(cls): return MutableList @@ -618,7 +618,7 @@ class _MutableListTestBase(_MutableListTestFixture): assert isinstance(obj, MutableList) -class _MutableSetTestFixture(object): +class _MutableSetTestFixture: @classmethod def _type_fixture(cls): return MutableSet @@ -853,7 +853,7 @@ class _MutableSetTestBase(_MutableSetTestFixture): eq_(f1.data, set([1, 2])) -class _MutableNoHashFixture(object): +class _MutableNoHashFixture: @testing.fixture(autouse=True, scope="class") def set_class(self): global Foo @@ -1057,7 +1057,7 @@ class MutableColumnCopyArrayTest(_MutableListTestBase, fixtures.MappedTest): Base = declarative_base(metadata=metadata) - class Mixin(object): + class Mixin: data = Column(MutableList.as_mutable(ARRAY(Integer))) class Foo(Mixin, Base): @@ -1279,7 +1279,7 @@ class CustomMutableAssociationScalarJSONTest( eq_(type(f1.data), self._type_fixture()) -class _CompositeTestBase(object): +class _CompositeTestBase: @classmethod def define_tables(cls, metadata): Table( diff --git a/test/ext/test_orderinglist.py b/test/ext/test_orderinglist.py index 031613bc4d..90c7f38578 100644 --- a/test/ext/test_orderinglist.py +++ b/test/ext/test_orderinglist.py @@ -91,14 +91,14 @@ class OrderingListTest(fixtures.MappedTest): Column("text", String(128)), ) - class Slide(object): + class Slide: def __init__(self, name): self.name = name def __repr__(self): return '' % self.name - class Bullet(object): + class Bullet: def __init__(self, text): self.text = text @@ -409,7 +409,7 @@ class OrderingListTest(fixtures.MappedTest): eq_([b.position for b in s1.bullets], [0, 1, 2]) def test_funky_ordering(self): - class Pos(object): + class Pos: def __init__(self): self.position = None @@ -481,7 +481,7 @@ class OrderingListTest(fixtures.MappedTest): self.assert_(copy.__dict__ == olist.__dict__) -class DummyItem(object): +class DummyItem: def __init__(self, order=None): self.order = order diff --git a/test/orm/_fixtures.py b/test/orm/_fixtures.py index 6715cb7fea..094568a376 100644 --- a/test/orm/_fixtures.py +++ b/test/orm/_fixtures.py @@ -396,7 +396,7 @@ class FixtureTest(fixtures.MappedTest): return CannedResults(self) -class CannedResults(object): +class CannedResults: """Built on demand, instances use mappers in effect at time of call.""" def __init__(self, test): diff --git a/test/orm/declarative/test_basic.py b/test/orm/declarative/test_basic.py index 0e3a48458b..f8cbdee365 100644 --- a/test/orm/declarative/test_basic.py +++ b/test/orm/declarative/test_basic.py @@ -191,7 +191,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_dispose_attrs(self): reg = registry() - class Foo(object): + class Foo: __tablename__ = "some_table" id = Column(Integer, primary_key=True) @@ -213,7 +213,7 @@ class DeclarativeTest(DeclarativeTestBase): ) def test_deferred_reflection_default_error(self): - class MyExt(object): + class MyExt: @classmethod def prepare(cls): "sample prepare method" @@ -358,7 +358,7 @@ class DeclarativeTest(DeclarativeTestBase): x = sa.sql.expression.column(Integer) y = Column(Integer) - class MyMixin(object): + class MyMixin: x = sa.sql.expression.column(Integer) y = Column(Integer) @@ -393,7 +393,7 @@ class DeclarativeTest(DeclarativeTestBase): r"non-schema 'sqlalchemy.sql.column\(\)' object; " ): - class MyMixin2(object): + class MyMixin2: @declared_attr def x(cls): return sa.sql.expression.column(Integer) @@ -1198,7 +1198,7 @@ class DeclarativeTest(DeclarativeTestBase): ) def test_custom_base(self): - class MyBase(object): + class MyBase: def foobar(self): return "foobar" @@ -1614,7 +1614,7 @@ class DeclarativeTest(DeclarativeTestBase): def test_table_cls_attribute_return_none(self): from sqlalchemy.schema import Column, PrimaryKeyConstraint - class AutoTable(object): + class AutoTable: @declared_attr def __tablename__(cls): return cls.__name__ @@ -2237,7 +2237,7 @@ class DeclarativeTest(DeclarativeTestBase): ) def test_cls_docstring(self): - class MyBase(object): + class MyBase: """MyBase Docstring""" Base = declarative_base(cls=MyBase) diff --git a/test/orm/declarative/test_clsregistry.py b/test/orm/declarative/test_clsregistry.py index b9d41ee532..8c63814759 100644 --- a/test/orm/declarative/test_clsregistry.py +++ b/test/orm/declarative/test_clsregistry.py @@ -10,7 +10,7 @@ from sqlalchemy.testing import mock from sqlalchemy.testing.util import gc_collect -class MockClass(object): +class MockClass: def __init__(self, base, name): self._sa_class_manager = mock.Mock(registry=base) tokens = name.split(".") @@ -19,7 +19,7 @@ class MockClass(object): self.metadata = MetaData() -class MockProp(object): +class MockProp: parent = "some_parent" diff --git a/test/orm/declarative/test_deprecations.py b/test/orm/declarative/test_deprecations.py index 7267a9aa22..0727baefd6 100644 --- a/test/orm/declarative/test_deprecations.py +++ b/test/orm/declarative/test_deprecations.py @@ -45,7 +45,7 @@ class BoundMetadataDeclarativeTest(fixtures.MappedTest): reg = registry(_bind=testing.db) @reg.mapped - class User(object): + class User: __tablename__ = "user" id = Column(Integer, primary_key=True) diff --git a/test/orm/declarative/test_inheritance.py b/test/orm/declarative/test_inheritance.py index 7e43e25595..ca3a6e6089 100644 --- a/test/orm/declarative/test_inheritance.py +++ b/test/orm/declarative/test_inheritance.py @@ -308,7 +308,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): discriminator = Column("type", String(50)) __mapper_args__ = {"polymorphic_on": discriminator} - class MyMixin(object): + class MyMixin: pass @@ -324,7 +324,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): assert class_mapper(Engineer).inherits is class_mapper(Person) def test_intermediate_abstract_class_on_classical(self): - class Person(object): + class Person: pass person_table = Table( @@ -357,7 +357,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): eq_(set(class_mapper(Manager).class_manager), {"id", "kind"}) def test_intermediate_unmapped_class_on_classical(self): - class Person(object): + class Person: pass person_table = Table( @@ -390,7 +390,7 @@ class DeclarativeInheritanceTest(DeclarativeTestBase): eq_(set(class_mapper(Manager).class_manager), {"id", "kind"}) def test_class_w_invalid_multiple_bases(self): - class Person(object): + class Person: pass person_table = Table( diff --git a/test/orm/declarative/test_mixin.py b/test/orm/declarative/test_mixin.py index f3feb5ddf2..3bad55d312 100644 --- a/test/orm/declarative/test_mixin.py +++ b/test/orm/declarative/test_mixin.py @@ -54,7 +54,7 @@ class DeclarativeTestBase(fixtures.TestBase, testing.AssertsExecutionResults): class DeclarativeMixinTest(DeclarativeTestBase): def test_simple_wbase(self): - class MyMixin(object): + class MyMixin: id = Column( Integer, primary_key=True, test_needs_autoincrement=True @@ -79,7 +79,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): eq_(obj.foo(), "bar1") def test_simple_wdecorator(self): - class MyMixin(object): + class MyMixin: id = Column( Integer, primary_key=True, test_needs_autoincrement=True @@ -138,7 +138,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): eq_(obj.foo(), "bar1") def test_unique_column(self): - class MyMixin(object): + class MyMixin: id = Column(Integer, primary_key=True) value = Column(String, unique=True) @@ -213,7 +213,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): def test_mixin_overrides_wbase(self): """test a mixin that overrides a column on a superclass.""" - class MixinA(object): + class MixinA: foo = Column(String(50)) class MixinB(MixinA): @@ -233,7 +233,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): def test_mixin_overrides_wdecorator(self): """test a mixin that overrides a column on a superclass.""" - class MixinA(object): + class MixinA: foo = Column(String(50)) class MixinB(MixinA): @@ -330,10 +330,10 @@ class DeclarativeMixinTest(DeclarativeTestBase): reg = registry() - class B1(object): + class B1: metadata = m1 - class B2(object): + class B2: metadata = m2 def fullname(self): @@ -361,7 +361,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): username = Column(String) @reg.mapped - class BUser(object): + class BUser: __tablename__ = "user" id = Column(Integer, primary_key=True) @@ -427,7 +427,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): eq_(MyModel.__table__.name, "mymodel") def test_classproperty_still_works(self): - class MyMixin(object): + class MyMixin: @classproperty def __tablename__(cls): return cls.__name__.lower() @@ -526,7 +526,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): """ - class MyMixin(object): + class MyMixin: foo = Column("foo", Integer) bar = Column("bar_newname", Integer) @@ -559,7 +559,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): __tablename__ = "person" id = Column(Integer, primary_key=True) - class Mixin(object): + class Mixin: @declared_attr def target_id(cls): return cls.__table__.c.get( @@ -607,7 +607,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): """ - class MyMixin(object): + class MyMixin: foo = Column("foo", Integer) bar = Column("bar_newname", Integer) @@ -685,7 +685,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): def test_declare_first_mixin(self): canary = mock.Mock() - class MyMixin(object): + class MyMixin: @classmethod def __declare_first__(cls): canary.declare_first__(cls) @@ -712,7 +712,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): def test_declare_first_base(self): canary = mock.Mock() - class MyMixin(object): + class MyMixin: @classmethod def __declare_first__(cls): canary.declare_first__(cls) @@ -969,7 +969,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): def test_mapper_args_custom_base(self): """test the @declared_attr approach from a custom base.""" - class Base(object): + class Base: @declared_attr def __tablename__(cls): return cls.__name__.lower() @@ -1087,7 +1087,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): eq_(Joined.__table__.kwargs, {"mysql_engine": "InnoDB"}) def test_col_copy_vs_declared_attr_joined_propagation(self): - class Mixin(object): + class Mixin: a = Column(Integer) @declared_attr @@ -1108,7 +1108,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): assert "b" not in B.__table__.c def test_col_copy_vs_declared_attr_joined_propagation_newname(self): - class Mixin(object): + class Mixin: a = Column("a1", Integer) @declared_attr @@ -1129,7 +1129,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): assert "b1" not in B.__table__.c def test_col_copy_vs_declared_attr_single_propagation(self): - class Mixin(object): + class Mixin: a = Column(Integer) @declared_attr @@ -1309,12 +1309,12 @@ class DeclarativeMixinTest(DeclarativeTestBase): assert model_col.type.__class__ is Integer def test_mixin_column_ordering(self): - class Foo(object): + class Foo: col1 = Column(Integer) col3 = Column(Integer) - class Bar(object): + class Bar: col2 = Column(Integer) col4 = Column(Integer) @@ -1330,7 +1330,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): ) def test_honor_class_mro_one(self): - class HasXMixin(object): + class HasXMixin: @declared_attr def x(self): return Column(Integer) @@ -1346,7 +1346,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): assert "x" not in Child.__table__.c def test_honor_class_mro_two(self): - class HasXMixin(object): + class HasXMixin: @declared_attr def x(self): return Column(Integer) @@ -1365,7 +1365,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): assert C().x() == "hi" def test_arbitrary_attrs_one(self): - class HasMixin(object): + class HasMixin: @declared_attr def some_attr(cls): return cls.__name__ + "SOME ATTR" @@ -1398,7 +1398,7 @@ class DeclarativeMixinTest(DeclarativeTestBase): def __init__(self, filter_, **kw): self.filter = filter_ - class FilterMixin(object): + class FilterMixin: @declared_attr def _filters(cls): return relationship( @@ -1490,7 +1490,7 @@ class DeclarativeMixinPropertyTest( DeclarativeTestBase, testing.AssertsCompiledSQL ): def test_column_property(self): - class MyMixin(object): + class MyMixin: @declared_attr def prop_hoho(cls): return column_property(Column("prop", String(50))) @@ -1540,7 +1540,7 @@ class DeclarativeMixinPropertyTest( """ - class MyMixin(object): + class MyMixin: @declared_attr def type_(cls): """this is a document.""" @@ -1566,7 +1566,7 @@ class DeclarativeMixinPropertyTest( from sqlalchemy.ext.hybrid import hybrid_property from sqlalchemy import inspect - class Mixin(object): + class Mixin: @hybrid_property def hp1(cls): return 42 @@ -1604,7 +1604,7 @@ class DeclarativeMixinPropertyTest( def test_correct_for_proxies_doesnt_impact_synonyms(self): from sqlalchemy import inspect - class Mixin(object): + class Mixin: @declared_attr def data_syn(cls): return synonym("data") @@ -1645,7 +1645,7 @@ class DeclarativeMixinPropertyTest( ) def test_column_in_mapper_args(self): - class MyMixin(object): + class MyMixin: @declared_attr def type_(cls): return Column(String(50)) @@ -1663,7 +1663,7 @@ class DeclarativeMixinPropertyTest( assert col.table is not None def test_column_in_mapper_args_used_multiple_times(self): - class MyMixin(object): + class MyMixin: version_id = Column(Integer) __mapper_args__ = {"version_id_col": version_id} @@ -1686,7 +1686,7 @@ class DeclarativeMixinPropertyTest( ) def test_deferred(self): - class MyMixin(object): + class MyMixin: @declared_attr def data(cls): return deferred(Column("data", String(50))) @@ -1709,7 +1709,7 @@ class DeclarativeMixinPropertyTest( assert "data" in d1.__dict__ def _test_relationship(self, usestring): - class RefTargetMixin(object): + class RefTargetMixin: @declared_attr def target_id(cls): return Column("target_id", ForeignKey("target.id")) @@ -1774,7 +1774,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_singleton_behavior_within_decl(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr def my_prop(cls): counter(cls) @@ -1824,7 +1824,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_singleton_gc(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr def my_prop(cls): counter(cls.__name__) @@ -1851,7 +1851,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): ) def test_can_we_access_the_mixin_straight(self): - class Mixin(object): + class Mixin: @declared_attr def my_prop(cls): return Column("x", Integer) @@ -1866,7 +1866,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): ) def test_can_we_access_the_mixin_straight_special_names(self): - class Mixin(object): + class Mixin: @declared_attr def __table_args__(cls): return (1, 2, 3) @@ -1881,7 +1881,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_non_decl_access(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr def __tablename__(cls): counter(cls) @@ -1914,7 +1914,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_property_noncascade(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr def my_prop(cls): counter(cls) @@ -1934,7 +1934,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_property_cascade_mixin(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr.cascading def my_prop(cls): counter(cls) @@ -1954,7 +1954,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_property_cascade_mixin_override(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr.cascading def my_prop(cls): counter(cls) @@ -2000,7 +2000,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): eq_(counter.mock_calls, [mock.call(A), mock.call(B)]) def test_warn_cascading_used_w_tablename(self): - class Mixin(object): + class Mixin: @declared_attr.cascading def __tablename__(cls): return "foo" @@ -2021,7 +2021,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): asserted = collections.defaultdict(set) - class Mixin(object): + class Mixin: @declared_attr.cascading def my_attr(cls): if has_inherited_table(cls): @@ -2071,7 +2071,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): def test_column_pre_map(self): counter = mock.Mock() - class Mixin(object): + class Mixin: @declared_attr def my_col(cls): counter(cls) @@ -2092,7 +2092,7 @@ class DeclaredAttrTest(DeclarativeTestBase, testing.AssertsCompiledSQL): counter = mock.Mock() - class HasAddressCount(object): + class HasAddressCount: id = Column(Integer, primary_key=True) @declared_attr @@ -2168,7 +2168,7 @@ class AbstractTest(DeclarativeTestBase): def test_implicit_abstract_viadecorator(self): @mapper_registry.mapped - class A(object): + class A: __tablename__ = "a" id = Column(Integer, primary_key=True) diff --git a/test/orm/inheritance/test_assorted_poly.py b/test/orm/inheritance/test_assorted_poly.py index 729e1ee047..66a722ccf2 100644 --- a/test/orm/inheritance/test_assorted_poly.py +++ b/test/orm/inheritance/test_assorted_poly.py @@ -249,7 +249,7 @@ class RelationshipTest2(fixtures.MappedTest): if usedata: - class Data(object): + class Data: def __init__(self, data): self.data = data @@ -553,7 +553,7 @@ class RelationshipTest4(fixtures.MappedTest): how to alias the primaryjoin to the polymorphic union ?""" # class definitions - class Person(object): + class Person: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -572,7 +572,7 @@ class RelationshipTest4(fixtures.MappedTest): self.longer_status, ) - class Car(object): + class Car: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -731,7 +731,7 @@ class RelationshipTest5(fixtures.MappedTest): """test parent object with child relationship to an inheriting mapper, using eager loads, works when there are no child objects present""" - class Person(object): + class Person: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -750,7 +750,7 @@ class RelationshipTest5(fixtures.MappedTest): self.longer_status, ) - class Car(object): + class Car: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -943,7 +943,7 @@ class RelationshipTest7(fixtures.MappedTest): """test that lazy load clause to a polymorphic child mapper generates correctly [ticket:493]""" - class PersistentObject(object): + class PersistentObject: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -1535,7 +1535,7 @@ class MultiLevelTest(fixtures.MappedTest): ) def test_threelevels(self): - class Employee(object): + class Employee: def set(me, **kargs): for k, v in kargs.items(): setattr(me, k, v) @@ -1666,13 +1666,13 @@ class ManyToManyPolyTest(fixtures.MappedTest): aren't attempted to be matched to the target polymorphic selectable""" - class BaseItem(object): + class BaseItem: pass class Item(BaseItem): pass - class Collection(object): + class Collection: pass item_join = polymorphic_union( @@ -1735,7 +1735,7 @@ class CustomPKTest(fixtures.MappedTest): """test that the primary_key attribute is propagated to the polymorphic mapper""" - class T1(object): + class T1: pass class T2(T1): @@ -1783,7 +1783,7 @@ class CustomPKTest(fixtures.MappedTest): """test that a composite primary key attribute formed by a join is "collapsed" into its minimal columns""" - class T1(object): + class T1: pass class T2(T1): diff --git a/test/orm/inheritance/test_basic.py b/test/orm/inheritance/test_basic.py index ac1661fdd1..339a6b9566 100644 --- a/test/orm/inheritance/test_basic.py +++ b/test/orm/inheritance/test_basic.py @@ -76,7 +76,7 @@ class O2MTest(fixtures.MappedTest): ) def test_basic(self): - class Foo(object): + class Foo: def __init__(self, data=None): self.data = data @@ -686,7 +686,7 @@ class FalseDiscriminatorTest(fixtures.MappedTest): ) def test_false_on_sub(self): - class Foo(object): + class Foo: pass class Bar(Foo): @@ -707,7 +707,7 @@ class FalseDiscriminatorTest(fixtures.MappedTest): assert isinstance(sess.query(Foo).one(), Bar) def test_false_on_base(self): - class Ding(object): + class Ding: pass class Bat(Ding): @@ -1480,10 +1480,10 @@ class FlushTest(fixtures.MappedTest): self.tables.user_roles, ) - class User(object): + class User: pass - class Role(object): + class Role: pass class Admin(User): @@ -1527,12 +1527,12 @@ class FlushTest(fixtures.MappedTest): self.tables.user_roles, ) - class User(object): + class User: def __init__(self, email=None, password=None): self.email = email self.password = password - class Role(object): + class Role: def __init__(self, description=None): self.description = description @@ -2090,7 +2090,7 @@ class DistinctPKTest(fixtures.MappedTest): Column("person_id", Integer, ForeignKey("persons.id")), ) - class Person(object): + class Person: def __init__(self, name): self.name = name @@ -2231,7 +2231,7 @@ class SyncCompileTest(fixtures.MappedTest): j1 = testing.resolve_lambda(j1, **locals()) j2 = testing.resolve_lambda(j2, **locals()) - class A(object): + class A: def __init__(self, **kwargs): for key, value in list(kwargs.items()): setattr(self, key, value) @@ -2310,7 +2310,7 @@ class OverrideColKeyTest(fixtures.MappedTest): def test_plain(self): # control case - class Base(object): + class Base: pass class Sub(Base): @@ -2331,7 +2331,7 @@ class OverrideColKeyTest(fixtures.MappedTest): # in particular, here we do a "manual" version of # what we'd like the mapper to do. - class Base(object): + class Base: pass class Sub(Base): @@ -2364,7 +2364,7 @@ class OverrideColKeyTest(fixtures.MappedTest): assert sess.get(Sub, 10) is s1 def test_override_onlyinparent(self): - class Base(object): + class Base: pass class Sub(Base): @@ -2403,7 +2403,7 @@ class OverrideColKeyTest(fixtures.MappedTest): # this is originally [ticket:1111]. # the pattern here is now disallowed by [ticket:1892] - class Base(object): + class Base: pass class Sub(Base): @@ -2428,7 +2428,7 @@ class OverrideColKeyTest(fixtures.MappedTest): assert_raises(sa_exc.InvalidRequestError, go) def test_pk_fk_different(self): - class Base(object): + class Base: pass class Sub(Base): @@ -2452,7 +2452,7 @@ class OverrideColKeyTest(fixtures.MappedTest): """test that descriptors prevent inheritance from propagating properties to subclasses.""" - class Base(object): + class Base: pass class Sub(Base): @@ -2473,13 +2473,13 @@ class OverrideColKeyTest(fixtures.MappedTest): """test that descriptors prevent inheritance from propagating properties to subclasses.""" - class MyDesc(object): + class MyDesc: def __get__(self, instance, owner): if instance is None: return self return "im the data" - class Base(object): + class Base: pass class Sub(Base): @@ -2495,7 +2495,7 @@ class OverrideColKeyTest(fixtures.MappedTest): assert sess.query(Sub).one().data == "im the data" def test_sub_columns_over_base_descriptors(self): - class Base(object): + class Base: @property def subdata(self): return "this is base" @@ -2521,7 +2521,7 @@ class OverrideColKeyTest(fixtures.MappedTest): assert sess.get(Sub, s1.base_id).subdata == "this is sub" def test_base_descriptors_over_base_cols(self): - class Base(object): + class Base: @property def data(self): return "this is base" @@ -2814,7 +2814,7 @@ class OptimizedLoadTest(fixtures.MappedTest): class WithComp(Base): pass - class Comp(object): + class Comp: def __init__(self, a, b): self.a = a self.b = b @@ -3022,7 +3022,7 @@ class NoPKOnSubTableWarningTest(fixtures.MappedTest): def test_warning_on_sub(self): parent, child = self._fixture() - class P(object): + class P: pass class C(P): @@ -3042,7 +3042,7 @@ class NoPKOnSubTableWarningTest(fixtures.MappedTest): def test_no_warning_with_explicit(self): parent, child = self._fixture() - class P(object): + class P: pass class C(P): @@ -3068,7 +3068,7 @@ class InhCondTest(fixtures.MappedTest): Column("owner_id", Integer, ForeignKey("owner.owner_id")), ) - class Base(object): + class Base: pass class Derived(Base): @@ -3094,7 +3094,7 @@ class InhCondTest(fixtures.MappedTest): ) Table("order", m, Column("id", Integer, primary_key=True)) - class Base(object): + class Base: pass class Derived(Base): @@ -3119,7 +3119,7 @@ class InhCondTest(fixtures.MappedTest): "derived", metadata, Column("id", Integer, primary_key=True) ) - class Base(object): + class Base: pass class Derived(Base): @@ -3154,7 +3154,7 @@ class InhCondTest(fixtures.MappedTest): Column("id", Integer, ForeignKey("base.id"), primary_key=True), ) - class Base(object): + class Base: pass class Derived(Base): @@ -3183,7 +3183,7 @@ class InhCondTest(fixtures.MappedTest): Column("id", Integer, ForeignKey("base.id"), primary_key=True), ) - class Base(object): + class Base: pass class Derived(Base): @@ -3216,7 +3216,7 @@ class InhCondTest(fixtures.MappedTest): Column("id", Integer, ForeignKey("base.q"), primary_key=True), ) - class Base(object): + class Base: pass class Derived(Base): @@ -3260,11 +3260,11 @@ class PKDiscriminatorTest(fixtures.MappedTest): def test_pk_as_discriminator(self): parents, children = self.tables.parents, self.tables.children - class Parent(object): + class Parent: def __init__(self, name=None): self.name = name - class Child(object): + class Child: def __init__(self, name=None): self.name = name @@ -3732,7 +3732,7 @@ class NameConflictTest(fixtures.MappedTest): ) def test_name_conflict(self): - class Content(object): + class Content: pass class Foo(Content): diff --git a/test/orm/inheritance/test_concrete.py b/test/orm/inheritance/test_concrete.py index d9dfa3d9e6..fae146755a 100644 --- a/test/orm/inheritance/test_concrete.py +++ b/test/orm/inheritance/test_concrete.py @@ -1400,7 +1400,7 @@ class ColKeysTest(fixtures.MappedTest): "pjoin", ) - class Location(object): + class Location: pass class Refugee(Location): diff --git a/test/orm/inheritance/test_manytomany.py b/test/orm/inheritance/test_manytomany.py index 60acab87d6..e366a349cf 100644 --- a/test/orm/inheritance/test_manytomany.py +++ b/test/orm/inheritance/test_manytomany.py @@ -76,7 +76,7 @@ class InheritTest(fixtures.MappedTest): ) def test_basic(self): - class Principal(object): + class Principal: def __init__(self, **kwargs): for key, value in kwargs.items(): setattr(self, key, value) @@ -151,7 +151,7 @@ class InheritTest2(fixtures.MappedTest): ) def test_get(self): - class Foo(object): + class Foo: def __init__(self, data=None): self.data = data @@ -173,7 +173,7 @@ class InheritTest2(fixtures.MappedTest): assert sess.get(Bar, b.id).id == b.id def test_basic(self): - class Foo(object): + class Foo: def __init__(self, data=None): self.data = data @@ -281,7 +281,7 @@ class InheritTest3(fixtures.MappedTest): ) def test_basic(self): - class Foo(object): + class Foo: def __init__(self, data=None): self.data = data @@ -317,7 +317,7 @@ class InheritTest3(fixtures.MappedTest): eq_(found, compare) def test_advanced(self): - class Foo(object): + class Foo: def __init__(self, data=None): self.data = data diff --git a/test/orm/inheritance/test_poly_linked_list.py b/test/orm/inheritance/test_poly_linked_list.py index ef3466ddf7..a501e027a5 100644 --- a/test/orm/inheritance/test_poly_linked_list.py +++ b/test/orm/inheritance/test_poly_linked_list.py @@ -71,7 +71,7 @@ class PolymorphicCircularTest(fixtures.MappedTest): join = table1.outerjoin(table2).outerjoin(table3).alias("pjoin") # join = None - class Table1(object): + class Table1: def __init__(self, name, data=None): self.name = name if data is not None: @@ -94,7 +94,7 @@ class PolymorphicCircularTest(fixtures.MappedTest): class Table3(Table1): pass - class Data(object): + class Data: def __init__(self, data): self.data = data diff --git a/test/orm/inheritance/test_poly_loading.py b/test/orm/inheritance/test_poly_loading.py index 00537a1fc5..fcaf470b45 100644 --- a/test/orm/inheritance/test_poly_loading.py +++ b/test/orm/inheritance/test_poly_loading.py @@ -32,7 +32,7 @@ from ._poly_fixtures import Manager from ._poly_fixtures import Person -class BaseAndSubFixture(object): +class BaseAndSubFixture: use_options = False @classmethod diff --git a/test/orm/inheritance/test_productspec.py b/test/orm/inheritance/test_productspec.py index cede0cbb5b..d7d8b9ec55 100644 --- a/test/orm/inheritance/test_productspec.py +++ b/test/orm/inheritance/test_productspec.py @@ -85,7 +85,7 @@ class InheritTest(fixtures.MappedTest): Column("size", Integer, default=0), ) - class Product(object): + class Product: def __init__(self, name, mark=""): self.name = name self.mark = mark @@ -110,7 +110,7 @@ class InheritTest(fixtures.MappedTest): ) ) - class SpecLine(object): + class SpecLine: def __init__(self, leader=None, follower=None, quantity=1): self.leader = leader self.follower = follower @@ -123,7 +123,7 @@ class InheritTest(fixtures.MappedTest): repr(self.follower), ) - class Document(object): + class Document: def __init__(self, name, data=None): self.name = name self.data = data diff --git a/test/orm/test_attributes.py b/test/orm/test_attributes.py index 130e980783..4d0a1b03cc 100644 --- a/test/orm/test_attributes.py +++ b/test/orm/test_attributes.py @@ -37,10 +37,10 @@ def _set_callable(state, dict_, key, callable_): class AttributeImplAPITest(fixtures.MappedTest): def _scalar_obj_fixture(self): - class A(object): + class A: pass - class B(object): + class B: pass instrumentation.register_class(A) @@ -49,10 +49,10 @@ class AttributeImplAPITest(fixtures.MappedTest): return A, B def _collection_obj_fixture(self): - class A(object): + class A: pass - class B(object): + class B: pass instrumentation.register_class(A) @@ -212,10 +212,10 @@ class AttributesTest(fixtures.ORMTest): def setup_test(self): global MyTest, MyTest2 - class MyTest(object): + class MyTest: pass - class MyTest2(object): + class MyTest2: pass def teardown_test(self): @@ -223,7 +223,7 @@ class AttributesTest(fixtures.ORMTest): MyTest, MyTest2 = None, None def test_basic(self): - class User(object): + class User: pass instrumentation.register_class(User) @@ -325,7 +325,7 @@ class AttributesTest(fixtures.ORMTest): """test that InstanceState always has a dict, even after host object gc'ed.""" - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -340,10 +340,10 @@ class AttributesTest(fixtures.ORMTest): @testing.requires.predictable_gc def test_object_dereferenced_error(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: def __init__(self): gc_collect() @@ -362,7 +362,7 @@ class AttributesTest(fixtures.ORMTest): ) def test_unmapped_instance_raises(self): - class User(object): + class User: pass instrumentation.register_class(User) @@ -370,7 +370,7 @@ class AttributesTest(fixtures.ORMTest): User, "user_name", uselist=False, useobject=False ) - class Blog(object): + class Blog: name = User.user_name def go(): @@ -383,7 +383,7 @@ class AttributesTest(fixtures.ORMTest): ) def test_del_scalar_nonobject(self): - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -408,10 +408,10 @@ class AttributesTest(fixtures.ORMTest): ) def test_del_scalar_object(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -435,10 +435,10 @@ class AttributesTest(fixtures.ORMTest): ) def test_del_collection_object(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -458,7 +458,7 @@ class AttributesTest(fixtures.ORMTest): eq_(f1.b, []) def test_deferred(self): - class Foo(object): + class Foo: pass data = {"a": "this is a", "b": 12} @@ -535,10 +535,10 @@ class AttributesTest(fixtures.ORMTest): eq_(m2.b, 12) def test_list(self): - class User(object): + class User: pass - class Address(object): + class Address: pass instrumentation.register_class(User) @@ -602,10 +602,10 @@ class AttributesTest(fixtures.ORMTest): """ - class Post(object): + class Post: pass - class Blog(object): + class Blog: pass instrumentation.register_class(Post) @@ -665,10 +665,10 @@ class AttributesTest(fixtures.ORMTest): assert attributes.has_parent(Post, b2, "blog") def test_illegal_trackparent(self): - class Post(object): + class Post: pass - class Blog(object): + class Blog: pass instrumentation.register_class(Post) @@ -695,7 +695,7 @@ class AttributesTest(fixtures.ORMTest): def test_inheritance(self): """tests that attributes are polymorphic""" - class Foo(object): + class Foo: pass class Bar(Foo): @@ -733,7 +733,7 @@ class AttributesTest(fixtures.ORMTest): def test_no_double_state(self): states = set() - class Foo(object): + class Foo: def __init__(self): states.add(attributes.instance_state(self)) @@ -754,13 +754,13 @@ class AttributesTest(fixtures.ORMTest): managed attributes of an object, if the object is of a descendant class with managed attributes in the parent class""" - class Foo(object): + class Foo: pass class Bar(Foo): pass - class Element(object): + class Element: _state = True instrumentation.register_class(Foo) @@ -819,10 +819,10 @@ class AttributesTest(fixtures.ORMTest): ) def test_parenttrack(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -862,18 +862,18 @@ class AttributesTest(fixtures.ORMTest): from ones implementing zope.interface.Interface). This is a simple regression test to prevent that defect.""" - class des(object): + class des: def __get__(self, instance, owner): raise AttributeError("fake attribute") - class Foo(object): + class Foo: A = des() instrumentation.register_class(Foo) instrumentation.unregister_class(Foo) def test_collectionclasses(self): - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -920,7 +920,7 @@ class AttributesTest(fixtures.ORMTest): assert isinstance(Foo().collection, MyDict) attributes.unregister_attribute(Foo, "collection") - class MyColl(object): + class MyColl: pass try: @@ -938,7 +938,7 @@ class AttributesTest(fixtures.ORMTest): "collection class" ) - class MyColl(object): + class MyColl: @collection.iterator def __iter__(self): return iter([]) @@ -965,7 +965,7 @@ class AttributesTest(fixtures.ORMTest): assert False def test_last_known_tracking(self): - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -1013,10 +1013,10 @@ class AttributesTest(fixtures.ORMTest): class GetNoValueTest(fixtures.ORMTest): def _fixture(self, expected): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass def lazy_callable(state, passive): @@ -1083,10 +1083,10 @@ class GetNoValueTest(fixtures.ORMTest): class UtilTest(fixtures.ORMTest): def test_helpers(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -1114,10 +1114,10 @@ class UtilTest(fixtures.ORMTest): """test that set_committed_value->None to a uselist generates an empty list""" - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -1137,10 +1137,10 @@ class UtilTest(fixtures.ORMTest): eq_(f1.col_set, set()) def test_initiator_arg(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -1173,10 +1173,10 @@ class UtilTest(fixtures.ORMTest): class BackrefTest(fixtures.ORMTest): def test_m2m(self): - class Student(object): + class Student: pass - class Course(object): + class Course: pass instrumentation.register_class(Student) @@ -1208,10 +1208,10 @@ class BackrefTest(fixtures.ORMTest): self.assert_(c.students == [s2, s3]) def test_o2m(self): - class Post(object): + class Post: pass - class Blog(object): + class Blog: pass instrumentation.register_class(Post) @@ -1256,10 +1256,10 @@ class BackrefTest(fixtures.ORMTest): del p5.blog def test_o2o(self): - class Port(object): + class Port: pass - class Jack(object): + class Jack: pass instrumentation.register_class(Port) @@ -1290,10 +1290,10 @@ class BackrefTest(fixtures.ORMTest): """ - class Parent(object): + class Parent: pass - class Child(object): + class Child: pass class SubChild(Child): @@ -1338,13 +1338,13 @@ class BackrefTest(fixtures.ORMTest): c2.parent = p1 def test_symmetric_o2m_inheritance(self): - class Parent(object): + class Parent: pass class SubParent(Parent): pass - class Child(object): + class Child: pass p_token = object() @@ -1431,13 +1431,13 @@ class CyclicBackrefAssertionTest(fixtures.TestBase): ) def _scalar_fixture(self): - class A(object): + class A: pass - class B(object): + class B: pass - class C(object): + class C: pass instrumentation.register_class(A) @@ -1456,13 +1456,13 @@ class CyclicBackrefAssertionTest(fixtures.TestBase): return A, B, C def _collection_fixture(self): - class A(object): + class A: pass - class B(object): + class B: pass - class C(object): + class C: pass instrumentation.register_class(A) @@ -1482,10 +1482,10 @@ class CyclicBackrefAssertionTest(fixtures.TestBase): return A, B, C def _broken_collection_fixture(self): - class A(object): + class A: pass - class B(object): + class B: pass instrumentation.register_class(A) @@ -1519,7 +1519,7 @@ class CyclicBackrefAssertionTest(fixtures.TestBase): class PendingBackrefTest(fixtures.ORMTest): def _fixture(self): - class Post(object): + class Post: def __init__(self, name): self.name = name @@ -1528,7 +1528,7 @@ class PendingBackrefTest(fixtures.ORMTest): def __eq__(self, other): return other is not None and other.name == self.name - class Blog(object): + class Blog: def __init__(self, name): self.name = name @@ -3237,10 +3237,10 @@ class ListenerTest(fixtures.ORMTest): def test_receive_changes(self): """test that Listeners can mutate the given value.""" - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass def append(state, child, initiator): @@ -3282,10 +3282,10 @@ class ListenerTest(fixtures.ORMTest): def test_named(self): canary = Mock() - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -3335,10 +3335,10 @@ class ListenerTest(fixtures.ORMTest): ) def test_collection_link_events(self): - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -3380,10 +3380,10 @@ class ListenerTest(fixtures.ORMTest): """ - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -3423,7 +3423,7 @@ class ListenerTest(fixtures.ORMTest): def test_flag_modified(self): canary = Mock() - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -3441,7 +3441,7 @@ class ListenerTest(fixtures.ORMTest): def test_none_init_scalar(self): canary = Mock() - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -3457,7 +3457,7 @@ class ListenerTest(fixtures.ORMTest): def test_none_init_object(self): canary = Mock() - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -3473,10 +3473,10 @@ class ListenerTest(fixtures.ORMTest): def test_none_init_collection(self): canary = Mock() - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass instrumentation.register_class(Foo) @@ -3584,7 +3584,7 @@ class EventPropagateTest(fixtures.TestBase): canary = [] def make_a(): - class A(object): + class A: pass classes[0] = A @@ -3602,7 +3602,7 @@ class EventPropagateTest(fixtures.TestBase): classes[2] = C def make_d(): - class D(object): + class D: pass classes[3] = D @@ -3691,10 +3691,10 @@ class EventPropagateTest(fixtures.TestBase): class CollectionInitTest(fixtures.TestBase): def setup_test(self): - class A(object): + class A: pass - class B(object): + class B: pass self.A = A @@ -3750,10 +3750,10 @@ class CollectionInitTest(fixtures.TestBase): class TestUnlink(fixtures.TestBase): def setup_test(self): - class A(object): + class A: pass - class B(object): + class B: pass self.A = A diff --git a/test/orm/test_cache_key.py b/test/orm/test_cache_key.py index 7fb232b0b8..5ed856a3c9 100644 --- a/test/orm/test_cache_key.py +++ b/test/orm/test_cache_key.py @@ -134,7 +134,7 @@ class CacheKeyTest(CacheKeyFixture, _fixtures.FixtureTest): from sqlalchemy import Column, Integer, String - class Foo(object): + class Foo: id = Column(Integer) name = Column(String) @@ -152,7 +152,7 @@ class CacheKeyTest(CacheKeyFixture, _fixtures.FixtureTest): def test_loader_criteria_bound_param_thing(self): from sqlalchemy import Column, Integer - class Foo(object): + class Foo: id = Column(Integer) def go(param): diff --git a/test/orm/test_cascade.py b/test/orm/test_cascade.py index 3617e3a5d5..c64c5a03a2 100644 --- a/test/orm/test_cascade.py +++ b/test/orm/test_cascade.py @@ -3593,14 +3593,14 @@ class OrphanCriterionTest(fixtures.MappedTest): r2_present, detach_event=True, ): - class Core(object): + class Core: pass - class RelatedOne(object): + class RelatedOne: def __init__(self, cores): self.cores = cores - class RelatedTwo(object): + class RelatedTwo: def __init__(self, cores): self.cores = cores @@ -4492,7 +4492,7 @@ class CollectionCascadesNoBackrefTest(fixtures.TestBase): def cascade_fixture(self, registry): def go(collection_class): @registry.mapped - class A(object): + class A: __tablename__ = "a" id = Column(Integer, primary_key=True) @@ -4504,7 +4504,7 @@ class CollectionCascadesNoBackrefTest(fixtures.TestBase): ) @registry.mapped - class B(object): + class B: __tablename__ = "b_" id = Column(Integer, primary_key=True) a_id = Column(ForeignKey("a.id")) diff --git a/test/orm/test_collection.py b/test/orm/test_collection.py index 90bb606cbc..ca14d7658f 100644 --- a/test/orm/test_collection.py +++ b/test/orm/test_collection.py @@ -27,7 +27,7 @@ from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table -class Canary(object): +class Canary: def __init__(self): self.data = set() self.added = set() @@ -77,14 +77,14 @@ class Canary(object): return value -class OrderedDictFixture(object): +class OrderedDictFixture: @testing.fixture def ordered_dict_mro(self): return type("ordered", (collections.MappedCollection,), {}) class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): - class Entity(object): + class Entity: def __init__(self, a=None, b=None, c=None): self.a = a self.b = b @@ -117,7 +117,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -170,7 +170,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -206,7 +206,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -451,7 +451,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -525,7 +525,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): # or __delslice__ methods. The __setitem__ # and __delitem__ must therefore accept # slice objects (i.e. as in py3k) - class ListLike(object): + class ListLike: def __init__(self): self.data = list() @@ -581,7 +581,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(getattr(MyList, "_sa_instrumented") == id(MyList)) def test_list_duck(self): - class ListLike(object): + class ListLike: def __init__(self): self.data = list() @@ -617,7 +617,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(getattr(ListLike, "_sa_instrumented") == id(ListLike)) def test_list_emulates(self): - class ListIsh(object): + class ListIsh: __emulates__ = list def __init__(self): @@ -658,7 +658,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -700,7 +700,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -968,7 +968,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -1032,7 +1032,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(getattr(MySet, "_sa_instrumented") == id(MySet)) def test_set_duck(self): - class SetLike(object): + class SetLike: def __init__(self): self.data = set() @@ -1068,7 +1068,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(getattr(SetLike, "_sa_instrumented") == id(SetLike)) def test_set_emulates(self): - class SetIsh(object): + class SetIsh: __emulates__ = set def __init__(self): @@ -1109,7 +1109,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.dictable_entity - class Foo(object): + class Foo: pass canary = Canary() @@ -1170,7 +1170,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.dictable_entity - class Foo(object): + class Foo: pass canary = Canary() @@ -1298,7 +1298,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.dictable_entity - class Foo(object): + class Foo: pass canary = Canary() @@ -1421,7 +1421,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(getattr(MyOrdered, "_sa_instrumented") == id(MyOrdered)) def test_dict_duck(self): - class DictLike(object): + class DictLike: def __init__(self): self.data = dict() @@ -1472,7 +1472,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(getattr(DictLike, "_sa_instrumented") == id(DictLike)) def test_dict_emulates(self): - class DictIsh(object): + class DictIsh: __emulates__ = dict def __init__(self): @@ -1528,7 +1528,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): if creator is None: creator = self.entity_maker - class Foo(object): + class Foo: pass canary = Canary() @@ -1579,7 +1579,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): assert_eq() def test_object_duck(self): - class MyCollection(object): + class MyCollection: def __init__(self): self.data = set() @@ -1613,7 +1613,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): ) def test_object_emulates(self): - class MyCollection2(object): + class MyCollection2: __emulates__ = None def __init__(self): @@ -1654,7 +1654,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): ) def test_recipes(self): - class Custom(object): + class Custom: def __init__(self): self.data = [] @@ -1689,7 +1689,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): def __iter__(self): return iter(self.data) - class Foo(object): + class Foo: pass canary = Canary() @@ -1762,7 +1762,7 @@ class CollectionsTest(OrderedDictFixture, fixtures.ORMTest): self.assert_(dr3 is cr3) def test_lifecycle(self): - class Foo(object): + class Foo: pass canary = Canary() @@ -2176,10 +2176,10 @@ class CustomCollectionsTest(fixtures.MappedTest): class MyList(list): pass - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass self.mapper_registry.map_imperatively( @@ -2199,10 +2199,10 @@ class CustomCollectionsTest(fixtures.MappedTest): self.tables.sometable, ) - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass self.mapper_registry.map_imperatively( @@ -2230,10 +2230,10 @@ class CustomCollectionsTest(fixtures.MappedTest): self.tables.sometable, ) - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass class AppenderDict(dict): @@ -2274,10 +2274,10 @@ class CustomCollectionsTest(fixtures.MappedTest): self.tables.sometable, ) - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: def __init__(self, data): self.data = data @@ -2324,7 +2324,7 @@ class CustomCollectionsTest(fixtures.MappedTest): self._test_list(list) def test_list_no_setslice(self): - class ListLike(object): + class ListLike: def __init__(self): self.data = list() @@ -2374,10 +2374,10 @@ class CustomCollectionsTest(fixtures.MappedTest): self.tables.sometable, ) - class Parent(object): + class Parent: pass - class Child(object): + class Child: pass self.mapper_registry.map_imperatively( @@ -2505,13 +2505,13 @@ class CustomCollectionsTest(fixtures.MappedTest): self.tables.sometable, ) - class Parent(object): + class Parent: pass - class Child(object): + class Child: pass - class MyCollection(object): + class MyCollection: def __init__(self): self.data = [] @@ -2566,7 +2566,7 @@ class CustomCollectionsTest(fixtures.MappedTest): class InstrumentationTest(fixtures.ORMTest): def test_uncooperative_descriptor_in_sweep(self): - class DoNotTouch(object): + class DoNotTouch: def __get__(self, obj, owner): raise AttributeError @@ -2580,7 +2580,7 @@ class InstrumentationTest(fixtures.ORMTest): collections._instrument_class(Touchy) def test_referenced_by_owner(self): - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) diff --git a/test/orm/test_compile.py b/test/orm/test_compile.py index 343881efc5..edf726f3c5 100644 --- a/test/orm/test_compile.py +++ b/test/orm/test_compile.py @@ -63,16 +63,16 @@ class CompileTest(fixtures.MappedTest): ), ) - class Order(object): + class Order: pass - class Employee(object): + class Employee: pass - class Product(object): + class Product: pass - class OrderProduct(object): + class OrderProduct: pass order_join = order.select().alias("pjoin") @@ -148,13 +148,13 @@ class CompileTest(fixtures.MappedTest): ), ) - class Order(object): + class Order: pass - class Product(object): + class Product: pass - class OrderProduct(object): + class OrderProduct: pass order_join = order.select().alias("pjoin") @@ -212,13 +212,13 @@ class CompileTest(fixtures.MappedTest): metadata.create_all(connection) connection.execute(node_table.insert(), dict(node_id=1, node_index=5)) - class Node(object): + class Node: pass - class NodeName(object): + class NodeName: pass - class Host(object): + class Host: pass self.mapper_registry.map_imperatively(Node, node_table) @@ -245,10 +245,10 @@ class CompileTest(fixtures.MappedTest): Column("a_id", Integer, ForeignKey("a.id")), ) - class A(object): + class A: pass - class B(object): + class B: pass self.mapper_registry.map_imperatively( @@ -273,10 +273,10 @@ class CompileTest(fixtures.MappedTest): Column("a_id", Integer, ForeignKey("a.id")), ) - class A(object): + class A: pass - class B(object): + class B: pass class C(B): diff --git a/test/orm/test_composites.py b/test/orm/test_composites.py index 55a78ffcbc..67ffae75da 100644 --- a/test/orm/test_composites.py +++ b/test/orm/test_composites.py @@ -442,7 +442,7 @@ class NestedTest(fixtures.MappedTest, testing.AssertsCompiledSQL): ) def _fixture(self): - class AB(object): + class AB: def __init__(self, a, b, cd): self.a = a self.b = b @@ -466,7 +466,7 @@ class NestedTest(fixtures.MappedTest, testing.AssertsCompiledSQL): def __ne__(self, other): return not self.__eq__(other) - class CD(object): + class CD: def __init__(self, c, d): self.c = c self.d = d @@ -484,7 +484,7 @@ class NestedTest(fixtures.MappedTest, testing.AssertsCompiledSQL): def __ne__(self, other): return not self.__eq__(other) - class Thing(object): + class Thing: def __init__(self, ab): self.ab = ab diff --git a/test/orm/test_core_compilation.py b/test/orm/test_core_compilation.py index 5d66e339ab..4bf196fa0d 100644 --- a/test/orm/test_core_compilation.py +++ b/test/orm/test_core_compilation.py @@ -2290,7 +2290,7 @@ class RawSelectTest(QueryTest, AssertsCompiledSQL): ) def test_col_prop_builtin_function(self): - class Foo(object): + class Foo: pass self.mapper_registry.map_imperatively( diff --git a/test/orm/test_deprecations.py b/test/orm/test_deprecations.py index 5fd876474c..962161f7b9 100644 --- a/test/orm/test_deprecations.py +++ b/test/orm/test_deprecations.py @@ -2870,7 +2870,7 @@ class DeprecatedMapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): __dialect__ = "default" def test_deferred_scalar_loader_name_change(self): - class Foo(object): + class Foo: pass def myloader(*arg, **kw): @@ -3108,7 +3108,7 @@ class InstrumentationTest(fixtures.ORMTest): for key, value in dictlike.items(): yield value + 5 - class Foo(object): + class Foo: pass instrumentation.register_class(Foo) @@ -3128,7 +3128,7 @@ class InstrumentationTest(fixtures.ORMTest): "AttributeEvents" ): - class Base(object): + class Base: @collection.iterator def base_iterate(self, x): return "base_iterate" @@ -3602,7 +3602,7 @@ class NonPrimaryMapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_illegal_non_primary_3(self): users, addresses = self.tables.users, self.tables.addresses - class Base(object): + class Base: pass class Sub(Base): @@ -3668,7 +3668,7 @@ class NonPrimaryMapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_illegal_non_primary_3_legacy(self): users, addresses = self.tables.users, self.tables.addresses - class Base(object): + class Base: pass class Sub(Base): @@ -4331,7 +4331,7 @@ class DeclarativeBind(fixtures.TestBase): ): @as_declarative(bind=testing.db) - class Base(object): + class Base: @declared_attr def __tablename__(cls): return cls.__name__.lower() @@ -5995,10 +5995,10 @@ class MultiplePathTest(fixtures.MappedTest, AssertsCompiledSQL): self.tables.t1, ) - class T1(object): + class T1: pass - class T2(object): + class T2: pass self.mapper_registry.map_imperatively( @@ -6037,7 +6037,7 @@ class BindSensitiveStringifyTest(fixtures.MappedTest): # building a totally separate metadata /mapping here # because we need to control if the MetaData is bound or not - class User(object): + class User: pass m = MetaData() @@ -8369,7 +8369,7 @@ class CollectionCascadesDespiteBackrefTest(fixtures.TestBase): def cascade_fixture(self, registry): def go(collection_class): @registry.mapped - class A(object): + class A: __tablename__ = "a" id = Column(Integer, primary_key=True) @@ -8378,7 +8378,7 @@ class CollectionCascadesDespiteBackrefTest(fixtures.TestBase): ) @registry.mapped - class B(object): + class B: __tablename__ = "b_" id = Column(Integer, primary_key=True) a_id = Column(ForeignKey("a.id")) diff --git a/test/orm/test_dynamic.py b/test/orm/test_dynamic.py index e037ef1918..5ea6131976 100644 --- a/test/orm/test_dynamic.py +++ b/test/orm/test_dynamic.py @@ -24,7 +24,7 @@ from sqlalchemy.testing.fixtures import fixture_session from test.orm import _fixtures -class _DynamicFixture(object): +class _DynamicFixture: def _user_address_fixture(self, addresses_args={}): users, Address, addresses, User = ( self.tables.users, @@ -628,7 +628,7 @@ class DynamicTest(_DynamicFixture, _fixtures.FixtureTest, AssertsCompiledSQL): ) item_keywords = self.tables.item_keywords - class ItemKeyword(object): + class ItemKeyword: pass self.mapper_registry.map_imperatively( diff --git a/test/orm/test_eager_relations.py b/test/orm/test_eager_relations.py index 32abc3b31c..9cefb51cbf 100644 --- a/test/orm/test_eager_relations.py +++ b/test/orm/test_eager_relations.py @@ -5408,13 +5408,13 @@ class CyclicalInheritingEagerTestOne(fixtures.MappedTest): def test_basic(self): t2, t1 = self.tables.t2, self.tables.t1 - class T(object): + class T: pass class SubT(T): pass - class T2(object): + class T2: pass class SubT2(T2): diff --git a/test/orm/test_events.py b/test/orm/test_events.py index 39d1e8ad96..aa17f2b6ce 100644 --- a/test/orm/test_events.py +++ b/test/orm/test_events.py @@ -48,7 +48,7 @@ from sqlalchemy.testing.util import gc_collect from test.orm import _fixtures -class _RemoveListeners(object): +class _RemoveListeners: @testing.fixture(autouse=True) def _remove_listeners(self): yield @@ -645,7 +645,7 @@ class MapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): canary = [] - class A(object): + class A: pass class B(A): @@ -734,7 +734,7 @@ class MapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): def test_init_failure_hook(self): users = self.tables.users - class Thing(object): + class Thing: def __init__(self, **kw): if kw.get("fail"): raise Exception("failure") @@ -1122,7 +1122,7 @@ class MapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): def test_instrument_class_precedes_class_instrumentation(self): users = self.tables.users - class MyClass(object): + class MyClass: pass class MySubClass(MyClass): @@ -1693,7 +1693,7 @@ class DeferredMapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): def test_isolation_instrument_event(self): User = self.classes.User - class Bar(object): + class Bar: pass canary = [] @@ -1710,7 +1710,7 @@ class DeferredMapperEventsTest(_RemoveListeners, _fixtures.FixtureTest): @testing.requires.predictable_gc def test_instrument_event_auto_remove(self): - class Bar(object): + class Bar: pass dispatch = instrumentation._instrumentation_factory.dispatch @@ -1858,7 +1858,7 @@ class RemovalTest(_fixtures.FixtureTest): def test_unmapped_listen(self): users = self.tables.users - class Foo(object): + class Foo: pass fn = Mock() @@ -1894,7 +1894,7 @@ class RemovalTest(_fixtures.FixtureTest): fn = Mock() - class User(object): + class User: pass event.listen(User, "load", fn) @@ -2130,7 +2130,7 @@ class SessionEventsTest(_RemoveListeners, _fixtures.FixtureTest): def my_listener_one(*arg, **kw): pass - class NotASession(object): + class NotASession: def __call__(self): return fixture_session() diff --git a/test/orm/test_inspect.py b/test/orm/test_inspect.py index 0917544cb6..f468fc5c24 100644 --- a/test/orm/test_inspect.py +++ b/test/orm/test_inspect.py @@ -65,7 +65,7 @@ class TestORMInspection(_fixtures.FixtureTest): assert not insp.is_aliased_class def test_mapper_selectable_fixed(self): - class Foo(object): + class Foo: pass class Bar(Foo): @@ -96,7 +96,7 @@ class TestORMInspection(_fixtures.FixtureTest): assert insp.is_aliased_class def test_not_mapped_class(self): - class Foo(object): + class Foo: pass assert_raises_message( @@ -107,7 +107,7 @@ class TestORMInspection(_fixtures.FixtureTest): ) def test_not_mapped_instance(self): - class Foo(object): + class Foo: pass assert_raises_message( @@ -408,7 +408,7 @@ class TestORMInspection(_fixtures.FixtureTest): class Thing(InspectionAttr): pass - class AnonClass(object): + class AnonClass: __foo__ = "bar" __bat__ = Thing() @@ -548,7 +548,7 @@ class %s(SuperCls): ) def test_all_orm_descriptors_pep520_classical(self): - class MyClass(object): + class MyClass: pass from sqlalchemy import Table, MetaData, Column, Integer diff --git a/test/orm/test_instrumentation.py b/test/orm/test_instrumentation.py index 9158b51151..6b999f9f86 100644 --- a/test/orm/test_instrumentation.py +++ b/test/orm/test_instrumentation.py @@ -44,7 +44,7 @@ class InitTest(fixtures.ORMTest): def test_ai(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -54,7 +54,7 @@ class InitTest(fixtures.ORMTest): def test_A(self): inits = [] - class A(object): + class A: pass self.register(A, inits) @@ -65,7 +65,7 @@ class InitTest(fixtures.ORMTest): def test_Ai(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -77,7 +77,7 @@ class InitTest(fixtures.ORMTest): def test_ai_B(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -97,7 +97,7 @@ class InitTest(fixtures.ORMTest): def test_ai_Bi(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -119,7 +119,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_bi(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -141,7 +141,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_Bi(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -165,7 +165,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_B(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -187,7 +187,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_Bi_Ci(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -230,7 +230,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_bi_Ci(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -271,7 +271,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_b_Ci(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -302,7 +302,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_B_Ci(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -335,7 +335,7 @@ class InitTest(fixtures.ORMTest): def test_Ai_B_C(self): inits = [] - class A(object): + class A: def __init__(self): inits.append((A, "__init__")) @@ -366,7 +366,7 @@ class InitTest(fixtures.ORMTest): def test_A_Bi_C(self): inits = [] - class A(object): + class A: pass self.register(A, inits) @@ -397,7 +397,7 @@ class InitTest(fixtures.ORMTest): def test_A_B_Ci(self): inits = [] - class A(object): + class A: pass self.register(A, inits) @@ -428,7 +428,7 @@ class InitTest(fixtures.ORMTest): def test_A_B_C(self): inits = [] - class A(object): + class A: pass self.register(A, inits) @@ -456,7 +456,7 @@ class InitTest(fixtures.ORMTest): eq_(inits, [(C, "init", C)]) def test_defaulted_init(self): - class X(object): + class X: def __init__(self_, a, b=123, c="abc"): self_.a = a self_.b = b @@ -469,10 +469,10 @@ class InitTest(fixtures.ORMTest): eq_(o.b, 123) eq_(o.c, "abc") - class Y(object): + class Y: unique = object() - class OutOfScopeForEval(object): + class OutOfScopeForEval: def __repr__(self_): # misleading repr return "123" @@ -502,7 +502,7 @@ class MapperInitTest(fixtures.MappedTest): ) def test_partially_mapped_inheritance(self): - class A(object): + class A: pass class B(A): @@ -521,7 +521,7 @@ class MapperInitTest(fixtures.MappedTest): assert_raises(sa.orm.exc.UnmappedClassError, class_mapper, C) def test_del_warning(self): - class A(object): + class A: def __del__(self): pass @@ -546,7 +546,7 @@ class OnLoadTest(fixtures.ORMTest): global A - class A(object): + class A: pass def canary(instance): @@ -566,7 +566,7 @@ class OnLoadTest(fixtures.ORMTest): class NativeInstrumentationTest(fixtures.MappedTest): def test_register_reserved_attribute(self): - class T(object): + class T: pass instrumentation.register_class(T) @@ -593,7 +593,7 @@ class NativeInstrumentationTest(fixtures.MappedTest): Column(instrumentation.ClassManager.STATE_ATTR, Integer), ) - class T(object): + class T: pass assert_raises(KeyError, self.mapper_registry.map_imperatively, T, t) @@ -606,7 +606,7 @@ class NativeInstrumentationTest(fixtures.MappedTest): Column(instrumentation.ClassManager.MANAGER_ATTR, Integer), ) - class T(object): + class T: pass assert_raises(KeyError, self.mapper_registry.map_imperatively, T, t) @@ -661,7 +661,7 @@ if util.py3k: exec( """ def _kw_only_fixture(self): - class A(object): + class A: def __init__(self, a, *, b, c): self.a = a self.b = b @@ -669,7 +669,7 @@ def _kw_only_fixture(self): return self._instrument(A) def _kw_plus_posn_fixture(self): - class A(object): + class A: def __init__(self, a, *args, b, c): self.a = a self.b = b @@ -677,7 +677,7 @@ def _kw_plus_posn_fixture(self): return self._instrument(A) def _kw_opt_fixture(self): - class A(object): + class A: def __init__(self, a, *, b, c="c"): self.a = a self.b = b @@ -701,7 +701,7 @@ class MiscTest(fixtures.MappedTest): Column("x", Integer), ) - class A(object): + class A: pass self.mapper_registry.map_imperatively(A, t) @@ -724,10 +724,10 @@ class MiscTest(fixtures.MappedTest): Column("t1_id", Integer, ForeignKey("t1.id")), ) - class A(object): + class A: pass - class B(object): + class B: pass self.mapper_registry.map_imperatively( @@ -739,7 +739,7 @@ class MiscTest(fixtures.MappedTest): assert not a.bs def test_uninstrument(self): - class A(object): + class A: pass manager = instrumentation.register_class(A) @@ -767,7 +767,7 @@ class MiscTest(fixtures.MappedTest): Column("t1_id", Integer, ForeignKey("t1.id")), ) - class Base(object): + class Base: def __init__(self, *args, **kwargs): pass @@ -810,11 +810,11 @@ class MiscTest(fixtures.MappedTest): Column("t1_id", Integer, ForeignKey("t1.id")), ) - class Base(object): + class Base: def __init__(self): pass - class Base_AKW(object): + class Base_AKW: def __init__(self, *args, **kwargs): pass diff --git a/test/orm/test_joins.py b/test/orm/test_joins.py index b9f036b1fe..988fad6629 100644 --- a/test/orm/test_joins.py +++ b/test/orm/test_joins.py @@ -2086,7 +2086,7 @@ class CreateJoinsTest(fixtures.MappedTest, AssertsCompiledSQL): Column("id", Integer, ForeignKey("base.id"), primary_key=True), ) - class Base(object): + class Base: pass class A(Base): diff --git a/test/orm/test_lambdas.py b/test/orm/test_lambdas.py index 5274271d9f..53766c434d 100644 --- a/test/orm/test_lambdas.py +++ b/test/orm/test_lambdas.py @@ -151,7 +151,7 @@ class LambdaTest(QueryTest, AssertsCompiledSQL): if use_indirect_access: def query(names): - class Foo(object): + class Foo: def __init__(self): self.u1 = aliased(User) diff --git a/test/orm/test_lazy_relations.py b/test/orm/test_lazy_relations.py index 3ebff5f43b..7f22929868 100644 --- a/test/orm/test_lazy_relations.py +++ b/test/orm/test_lazy_relations.py @@ -806,7 +806,7 @@ class LazyTest(_fixtures.FixtureTest): """ @registry.mapped - class A(object): + class A: __tablename__ = "a" id = Column(Integer, primary_key=True) @@ -815,7 +815,7 @@ class LazyTest(_fixtures.FixtureTest): b = relationship("B") @registry.mapped - class B(object): + class B: __tablename__ = "b" id = Column(Integer, primary_key=True) diff --git a/test/orm/test_mapper.py b/test/orm/test_mapper.py index ec1ef37962..073f481191 100644 --- a/test/orm/test_mapper.py +++ b/test/orm/test_mapper.py @@ -167,7 +167,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): from sqlalchemy.orm.base import _is_mapped_class, _is_aliased_class - class Foo(object): + class Foo: x = "something" @property @@ -206,7 +206,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): from sqlalchemy.orm.base import _entity_descriptor - class Foo(object): + class Foo: x = "something" @property @@ -386,11 +386,11 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): users, addresses = self.tables.users, self.tables.addresses - class Foo(object): + class Foo: def __init__(self): pass - class Bar(object): + class Bar: pass self.mapper(Foo, users) @@ -406,7 +406,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): """ - class Foo(object): + class Foo: def __init__(self, id_): self.id = id_ @@ -547,7 +547,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_class_hier_only_instrument_once_multiple_configure(self): users, addresses = (self.tables.users, self.tables.addresses) - class A(object): + class A: pass class ASub(A): @@ -556,7 +556,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): class ASubSub(ASub): pass - class B(object): + class B: pass from sqlalchemy.testing import mock @@ -630,7 +630,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): users = self.tables.users Address = self.classes.Address - class MyComposite(object): + class MyComposite: pass for constructor, args in [ @@ -899,7 +899,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): assert_calls = [] - class Address(object): + class Address: def _get_user(self): assert_calls.append("get") return self._user @@ -941,7 +941,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): Column("parent_id", Integer, ForeignKey("nodes.id")), ) - class Node(object): + class Node: pass self.mapper( @@ -1000,7 +1000,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): Column("vendor_id", Integer), ) - class Person(object): + class Person: pass class Vendor(Person): @@ -1012,23 +1012,23 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): class Manager(Employee): pass - class Hoho(object): + class Hoho: pass - class Lala(object): + class Lala: pass - class Fub(object): + class Fub: pass - class Frob(object): + class Frob: pass - class HasDef(object): + class HasDef: def name(self): pass - class Empty(object): + class Empty: pass self.mapper( @@ -1170,7 +1170,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): t.create(connection) - class A(object): + class A: pass self.mapper(A, t, include_properties=["id"]) @@ -1179,7 +1179,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): s.commit() def test_we_dont_call_bool(self): - class NoBoolAllowed(object): + class NoBoolAllowed: def __bool__(self): raise Exception("nope") @@ -1192,7 +1192,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): assert s.get(NoBoolAllowed, u1.id) is u1 def test_we_dont_call_eq(self): - class NoEqAllowed(object): + class NoEqAllowed: def __eq__(self, other): raise Exception("nope") @@ -1571,7 +1571,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): class extendedproperty(property): attribute = 123 - class User(object): + class User: def _get_name(self): assert_col.append(("get", self.name)) return self.name @@ -1669,7 +1669,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): # synonym points to non-existent attrbute that hasn't been mapped yet. users = self.tables.users - class User(object): + class User: def _x(self): return self.id @@ -1691,7 +1691,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): assert hasattr(User.x, "comparator") def test_synonym_of_non_property_raises(self): - class User(object): + class User: @property def x(self): return "hi" @@ -1756,7 +1756,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): assert_col = [] - class User(object): + class User: def _get_name(self): assert_col.append(("get", self._name)) return self._name @@ -1886,7 +1886,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class User(object): + class User: @reconstructor def reconstruct(self): recon.append("go") @@ -1903,7 +1903,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class A(object): + class A: @reconstructor def reconstruct(self): assert isinstance(self, A) @@ -1944,7 +1944,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class User(object): + class User: @reconstructor def __init__(self): recon.append("go") @@ -1965,11 +1965,11 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class recon_obj(object): + class recon_obj: def __call__(self, obj): recon.append("go") - class User(object): + class User: __init__ = reconstructor(recon_obj()) self.mapper(User, users) @@ -1993,19 +1993,19 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class recon_obj(object): + class recon_obj: def __call__(self, obj): recon.append("go") __sa_reconstructor__ = True - class recon_meth(object): + class recon_meth: __func__ = recon_obj() def __call__(self, *arg, **kw): return self.__func__.__call__(*arg, **kw) - class User(object): + class User: __init__ = recon_meth() self.mapper(User, users) @@ -2022,7 +2022,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class A(object): + class A: @reconstructor def __init__(self): assert isinstance(self, A) @@ -2063,7 +2063,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): recon = [] - class Base(object): + class Base: @reconstructor def reconstruct(self): recon.append("go") @@ -2163,7 +2163,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_unmapped_subclass_error_postmap(self): users = self.tables.users - class Base(object): + class Base: pass class Sub(Base): @@ -2186,7 +2186,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_unmapped_subclass_error_premap(self): users = self.tables.users - class Base(object): + class Base: pass self.mapper(Base, users) @@ -2213,7 +2213,7 @@ class MapperTest(_fixtures.FixtureTest, AssertsCompiledSQL): class OldStyle: pass - class NewStyle(object): + class NewStyle: pass class A(NewStyle, OldStyle): @@ -2277,7 +2277,7 @@ class RequirementsTest(fixtures.MappedTest): Column("value", String(10)), ) - class _ValueBase(object): + class _ValueBase: def __init__(self, value="abc", id_=None): self.id = id_ self.value = value @@ -2456,7 +2456,7 @@ class RequirementsTest(fixtures.MappedTest): def test_nonzero_len_recursion(self): ht1 = self.tables.ht1 - class H1(object): + class H1: def __len__(self): return len(self.get_value()) @@ -2464,7 +2464,7 @@ class RequirementsTest(fixtures.MappedTest): self.value = "foobar" return self.value - class H2(object): + class H2: def __bool__(self): return bool(self.get_value()) @@ -2495,7 +2495,7 @@ class IsUserlandTest(fixtures.MappedTest): ) def _test(self, value, instancelevel=None): - class Foo(object): + class Foo: someprop = value m = self.mapper(Foo, self.tables.foo) @@ -2508,7 +2508,7 @@ class IsUserlandTest(fixtures.MappedTest): assert self.tables.foo.c.someprop not in m._columntoproperty def _test_not(self, value): - class Foo(object): + class Foo: someprop = value m = self.mapper(Foo, self.tables.foo) @@ -2632,7 +2632,7 @@ class MagicNamesTest(fixtures.MappedTest): Column(reserved, Integer), ) - class T(object): + class T: pass clear_mappers() @@ -2655,7 +2655,7 @@ class MagicNamesTest(fixtures.MappedTest): sa.orm.instrumentation.ClassManager.MANAGER_ATTR, ): - class M(object): + class M: pass clear_mappers() @@ -2705,10 +2705,10 @@ class DocumentTest(fixtures.TestBase): ), ) - class Foo(object): + class Foo: pass - class Bar(object): + class Bar: pass self.mapper( @@ -2767,7 +2767,7 @@ class ComparatorFactoryTest(_fixtures.FixtureTest, AssertsCompiledSQL): def test_kwarg_accepted(self): users, Address = self.tables.users, self.classes.Address - class DummyComposite(object): + class DummyComposite: def __init__(self, x, y): pass @@ -2937,18 +2937,18 @@ class RegistryConfigDisposeTest(fixtures.TestBase): ab = bc = True @reg1.mapped - class A(object): + class A: __tablename__ = "a" id = Column(Integer, primary_key=True) @reg2.mapped - class B(object): + class B: __tablename__ = "b" id = Column(Integer, primary_key=True) a_id = Column(ForeignKey(A.id)) @reg3.mapped - class C(object): + class C: __tablename__ = "c" id = Column(Integer, primary_key=True) b_id = Column(ForeignKey(B.id)) diff --git a/test/orm/test_merge.py b/test/orm/test_merge.py index bc79140278..8866223cc8 100644 --- a/test/orm/test_merge.py +++ b/test/orm/test_merge.py @@ -1399,7 +1399,7 @@ class MergeTest(_fixtures.FixtureTest): def test_synonym(self): users = self.tables.users - class User(object): + class User: def _getValue(self): return self._value diff --git a/test/orm/test_of_type.py b/test/orm/test_of_type.py index 09b3cf51c0..9348032442 100644 --- a/test/orm/test_of_type.py +++ b/test/orm/test_of_type.py @@ -30,7 +30,7 @@ from .inheritance._poly_fixtures import Manager from .inheritance._poly_fixtures import Person -class _PolymorphicTestBase(object): +class _PolymorphicTestBase: __dialect__ = "default" def test_any_one(self): diff --git a/test/orm/test_options.py b/test/orm/test_options.py index 1a2a5ba70f..dcb2103291 100644 --- a/test/orm/test_options.py +++ b/test/orm/test_options.py @@ -75,7 +75,7 @@ class QueryTest(_fixtures.FixtureTest): ) -class PathTest(object): +class PathTest: def _make_path(self, path): r = [] for i, item in enumerate(path): diff --git a/test/orm/test_pickled.py b/test/orm/test_pickled.py index 11d90bd590..2072b60e38 100644 --- a/test/orm/test_pickled.py +++ b/test/orm/test_pickled.py @@ -600,7 +600,7 @@ class PickleTest(fixtures.MappedTest): pickle.loads(pickle.dumps(screen2)) def test_exceptions(self): - class Foo(object): + class Foo: pass users = self.tables.users diff --git a/test/orm/test_query.py b/test/orm/test_query.py index 5c17cdaefb..5bbe150c05 100644 --- a/test/orm/test_query.py +++ b/test/orm/test_query.py @@ -1005,7 +1005,7 @@ class RowLabelingTest(QueryTest): @testing.fixture def uname_fixture(self): - class Foo(object): + class Foo: pass if False: @@ -1341,7 +1341,7 @@ class GetTest(QueryTest): def test_unique_param_names(self): users = self.tables.users - class SomeUser(object): + class SomeUser: pass s = users.select().where(users.c.id != 12).alias("users") @@ -7714,7 +7714,7 @@ class QueryClsTest(QueryTest): return MyQuery def _callable_fixture(self): - class MyQueryFactory(object): + class MyQueryFactory: def __call__(self, *arg, **kw): return Query(*arg, **kw) diff --git a/test/orm/test_rel_fn.py b/test/orm/test_rel_fn.py index 6f6b0d56df..dfce8e3829 100644 --- a/test/orm/test_rel_fn.py +++ b/test/orm/test_rel_fn.py @@ -24,7 +24,7 @@ from sqlalchemy.testing import is_ from sqlalchemy.testing import mock -class _JoinFixtures(object): +class _JoinFixtures: @classmethod def setup_test_class(cls): m = MetaData() diff --git a/test/orm/test_relationship_criteria.py b/test/orm/test_relationship_criteria.py index 7e2c6e04f9..b2c16da057 100644 --- a/test/orm/test_relationship_criteria.py +++ b/test/orm/test_relationship_criteria.py @@ -104,7 +104,7 @@ class _Fixtures(_fixtures.FixtureTest): def mixin_fixture(self): users = self.tables.users - class HasFoob(object): + class HasFoob: name = Column(String) class UserWFoob(HasFoob, self.Comparable): @@ -120,7 +120,7 @@ class _Fixtures(_fixtures.FixtureTest): def declattr_mixin_fixture(self): users = self.tables.users - class HasFoob(object): + class HasFoob: @declared_attr def name(cls): return Column(String) @@ -139,7 +139,7 @@ class _Fixtures(_fixtures.FixtureTest): orders, items = self.tables.orders, self.tables.items order_items = self.tables.order_items - class HasFoob(object): + class HasFoob: description = Column(String) class HasBat(HasFoob): @@ -894,7 +894,7 @@ class LoaderCriteriaTest(_Fixtures, testing.AssertsCompiledSQL): class TemporalFixtureTest(testing.fixtures.DeclarativeMappedTest): @classmethod def setup_classes(cls): - class HasTemporal(object): + class HasTemporal: """Mixin that identifies a class as having a timestamp column""" timestamp = Column( diff --git a/test/orm/test_relationships.py b/test/orm/test_relationships.py index 98de9abad7..94e74992fb 100644 --- a/test/orm/test_relationships.py +++ b/test/orm/test_relationships.py @@ -47,7 +47,7 @@ from sqlalchemy.testing.schema import Table from test.orm import _fixtures -class _RelationshipErrors(object): +class _RelationshipErrors: def _assert_raises_no_relevant_fks( self, fn, expr, relname, primary, *arg, **kw ): @@ -2516,10 +2516,10 @@ class JoinConditionErrorTest(fixtures.TestBase): ) t2 = Table("t2", m, Column("id", Integer, primary_key=True)) - class C1(object): + class C1: pass - class C2(object): + class C2: pass registry.map_imperatively( @@ -2577,10 +2577,10 @@ class JoinConditionErrorTest(fixtures.TestBase): Column("t1id", Integer, ForeignKey("t1.id")), ) - class C1(object): + class C1: pass - class C2(object): + class C2: pass registry.map_imperatively(C1, t1, properties={"c2": relationship(C2)}) @@ -2599,10 +2599,10 @@ class JoinConditionErrorTest(fixtures.TestBase): Column("t1id", Integer), ) - class C1(object): + class C1: pass - class C2(object): + class C2: pass registry.map_imperatively(C1, t1, properties={"c2": relationship(C2)}) @@ -3507,10 +3507,10 @@ class ViewOnlyLocalRemoteM2M(fixtures.TestBase): Column("t2_id", Integer, ForeignKey("t2.id")), ) - class A(object): + class A: pass - class B(object): + class B: pass registry.map_imperatively(B, t2) @@ -5558,7 +5558,7 @@ class ActiveHistoryFlagTest(_fixtures.FixtureTest): def test_composite_property_flag(self): Order, orders = self.classes.Order, self.tables.orders - class MyComposite(object): + class MyComposite: def __init__(self, description, isopen): self.description = description self.isopen = isopen diff --git a/test/orm/test_session.py b/test/orm/test_session.py index e31acf0246..c11897ea55 100644 --- a/test/orm/test_session.py +++ b/test/orm/test_session.py @@ -970,7 +970,7 @@ class SessionStateTest(_fixtures.FixtureTest): sess = fixture_session() - class Foo(object): + class Foo: def __init__(self): sess.add(self) @@ -1988,7 +1988,7 @@ class SessionInterface(fixtures.MappedTest): # flush will no-op without something in the unit of work def _(): - class OK(object): + class OK: pass self._map_it(OK) @@ -2058,7 +2058,7 @@ class SessionInterface(fixtures.MappedTest): ) def test_unmapped_instance(self): - class Unmapped(object): + class Unmapped: pass self._test_instance_guards(Unmapped()) @@ -2070,14 +2070,14 @@ class SessionInterface(fixtures.MappedTest): self._test_class_guards(prim, is_class=False) def test_unmapped_class_for_instance(self): - class Unmapped(object): + class Unmapped: pass self._test_instance_guards(Unmapped) self._test_class_guards(Unmapped) def test_mapped_class_for_instance(self): - class Mapped(object): + class Mapped: pass self._map_it(Mapped) @@ -2086,7 +2086,7 @@ class SessionInterface(fixtures.MappedTest): # no class guards- it would pass. def test_missing_state(self): - class Mapped(object): + class Mapped: pass early = Mapped() @@ -2096,7 +2096,7 @@ class SessionInterface(fixtures.MappedTest): self._test_class_guards(early, is_class=False) def test_refresh_arg_signature(self): - class Mapped(object): + class Mapped: pass self._map_it(Mapped) diff --git a/test/orm/test_subquery_relations.py b/test/orm/test_subquery_relations.py index 5be0042b0d..e07da638f2 100644 --- a/test/orm/test_subquery_relations.py +++ b/test/orm/test_subquery_relations.py @@ -2831,13 +2831,13 @@ class CyclicalInheritingEagerTestOne(fixtures.MappedTest): def test_basic(self): t2, t1 = self.tables.t2, self.tables.t1 - class T(object): + class T: pass class SubT(T): pass - class T2(object): + class T2: pass class SubT2(T2): diff --git a/test/orm/test_sync.py b/test/orm/test_sync.py index 924ae674eb..796ad84f98 100644 --- a/test/orm/test_sync.py +++ b/test/orm/test_sync.py @@ -14,7 +14,7 @@ from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table -class AssertsUOW(object): +class AssertsUOW: def _get_test_uow(self, session): uow = unitofwork.UOWTransaction(session) deleted = set(session._deleted) diff --git a/test/orm/test_transaction.py b/test/orm/test_transaction.py index fa16d269a0..3574c45074 100644 --- a/test/orm/test_transaction.py +++ b/test/orm/test_transaction.py @@ -2455,7 +2455,7 @@ class NaturalPKRollbackTest(fixtures.MappedTest): assert s.identity_map[identity_key(User, ("u1",))] is u1 -class JoinIntoAnExternalTransactionFixture(object): +class JoinIntoAnExternalTransactionFixture: """Test the "join into an external transaction" examples""" __leave_connections_for_teardown__ = True @@ -2512,7 +2512,7 @@ class NewStyleJoinIntoAnExternalTransactionTest( # begin a non-ORM transaction self.trans = self.connection.begin() - class A(object): + class A: pass clear_mappers() @@ -2579,7 +2579,7 @@ class LegacyJoinIntoAnExternalTransactionTest( # begin a non-ORM transaction self.trans = self.connection.begin() - class A(object): + class A: pass # TODO: py2 is not hitting this correctly for some reason, diff --git a/test/orm/test_unitofwork.py b/test/orm/test_unitofwork.py index d3afab3269..4ae842c4be 100644 --- a/test/orm/test_unitofwork.py +++ b/test/orm/test_unitofwork.py @@ -37,7 +37,7 @@ from sqlalchemy.util import ue from test.orm import _fixtures -class UnitOfWorkTest(object): +class UnitOfWorkTest: pass @@ -627,7 +627,7 @@ class ClauseAttributesTest(fixtures.MappedTest): eq_(hb.value, False) def test_clauseelement_accessor(self): - class Thing(object): + class Thing: def __init__(self, value): self.value = value @@ -2191,7 +2191,7 @@ class SaveTest(_fixtures.FixtureTest): names = [] - class Events(object): + class Events: def before_insert(self, mapper, connection, instance): self.current_instance = instance names.append(instance.name) @@ -3496,7 +3496,7 @@ class PartialNullPKTest(fixtures.MappedTest): class EnsurePKSortableTest(fixtures.MappedTest): - class SomeEnum(object): + class SomeEnum: # Implements PEP 435 in the minimal fashion needed by SQLAlchemy __members__ = OrderedDict() diff --git a/test/orm/test_unitofworkv2.py b/test/orm/test_unitofworkv2.py index fac4897bbd..efd581db2a 100644 --- a/test/orm/test_unitofworkv2.py +++ b/test/orm/test_unitofworkv2.py @@ -41,7 +41,7 @@ from sqlalchemy.testing.schema import Table from test.orm import _fixtures -class AssertsUOW(object): +class AssertsUOW: def _get_test_uow(self, session): uow = unitofwork.UOWTransaction(session) deleted = set(session._deleted) @@ -2833,11 +2833,11 @@ class TypeWoBoolTest(fixtures.MappedTest, testing.AssertsExecutionResults): def define_tables(cls, metadata): from sqlalchemy import TypeDecorator - class NoBool(object): + class NoBool: def __nonzero__(self): raise NotImplementedError("not supported") - class MyWidget(object): + class MyWidget: def __init__(self, text): self.text = text diff --git a/test/orm/test_update_delete.py b/test/orm/test_update_delete.py index 21863c57a5..b2743024ab 100644 --- a/test/orm/test_update_delete.py +++ b/test/orm/test_update_delete.py @@ -195,7 +195,7 @@ class UpdateDeleteTest(fixtures.MappedTest): def test_evaluate_clauseelement(self): User = self.classes.User - class Thing(object): + class Thing: def __clause_element__(self): return User.name.__clause_element__() @@ -209,7 +209,7 @@ class UpdateDeleteTest(fixtures.MappedTest): def test_evaluate_invalid(self): User = self.classes.User - class Thing(object): + class Thing: def __clause_element__(self): return 5 @@ -236,7 +236,7 @@ class UpdateDeleteTest(fixtures.MappedTest): eq_(jill.name, "moonbeam") def test_evaluate_synonym_string(self): - class Foo(object): + class Foo: pass self.mapper_registry.map_imperatively( @@ -251,7 +251,7 @@ class UpdateDeleteTest(fixtures.MappedTest): eq_(jill.uname, "moonbeam") def test_evaluate_synonym_attr(self): - class Foo(object): + class Foo: pass self.mapper_registry.map_imperatively( @@ -266,7 +266,7 @@ class UpdateDeleteTest(fixtures.MappedTest): eq_(jill.uname, "moonbeam") def test_evaluate_double_synonym_attr(self): - class Foo(object): + class Foo: pass self.mapper_registry.map_imperatively( diff --git a/test/orm/test_utils.py b/test/orm/test_utils.py index ba16d7e9a5..748ef152db 100644 --- a/test/orm/test_utils.py +++ b/test/orm/test_utils.py @@ -46,7 +46,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): return table def test_simple(self): - class Point(object): + class Point: pass table = self._fixture(Point) @@ -61,7 +61,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): assert alias.id.__clause_element__().table is not table def test_named_entity(self): - class Point(object): + class Point: pass self._fixture(Point) @@ -73,7 +73,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_named_selectable(self): - class Point(object): + class Point: pass table = self._fixture(Point) @@ -85,7 +85,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_not_instantiatable(self): - class Point(object): + class Point: pass self._fixture(Point) @@ -94,7 +94,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): assert_raises(TypeError, alias) def test_instancemethod(self): - class Point(object): + class Point: def zero(self): self.x, self.y = 0, 0 @@ -106,7 +106,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): assert getattr(alias, "zero") def test_classmethod(self): - class Point(object): + class Point: @classmethod def max_x(cls): return 100 @@ -119,7 +119,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): assert Point.max_x() == alias.max_x() == 100 def test_simple_property(self): - class Point(object): + class Point: @property def max_x(self): return 100 @@ -133,7 +133,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): assert Point.max_x is alias.max_x def test_descriptors(self): - class descriptor(object): + class descriptor: def __init__(self, fn): self.fn = fn @@ -146,7 +146,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): def method(self): return "method" - class Point(object): + class Point: center = (0, 0) @descriptor @@ -171,7 +171,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): assert child.table is table def test_hybrid_descriptor_one(self): - class Point(object): + class Point: def __init__(self, x, y): self.x, self.y = x, y @@ -191,7 +191,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_hybrid_descriptor_two(self): - class Point(object): + class Point: def __init__(self, x, y): self.x, self.y = x, y @@ -217,7 +217,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_hybrid_descriptor_three(self): - class Point(object): + class Point: def __init__(self, x, y): self.x, self.y = x, y @@ -289,7 +289,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_proxy_descriptor_one(self): - class Point(object): + class Point: def __init__(self, x, y): self.x, self.y = x, y @@ -407,7 +407,7 @@ class AliasedClassTest(fixtures.MappedTest, AssertsCompiledSQL): ) def test_parententity_vs_parentmapper(self): - class Point(object): + class Point: pass self._fixture(Point, properties={"x_syn": synonym("x")}) diff --git a/test/orm/test_validators.py b/test/orm/test_validators.py index 1c491e75f6..817d0fbc53 100644 --- a/test/orm/test_validators.py +++ b/test/orm/test_validators.py @@ -256,7 +256,7 @@ class ValidatorTest(_fixtures.FixtureTest): users = self.tables.users canary = Mock() - class SomeValidator(object): + class SomeValidator: def __call__(self, obj, key, name): canary(key, name) ne_(name, "fred") @@ -272,7 +272,7 @@ class ValidatorTest(_fixtures.FixtureTest): def test_validator_multi_warning(self): users = self.tables.users - class Foo(object): + class Foo: @validates("name") def validate_one(self, key, value): pass @@ -290,7 +290,7 @@ class ValidatorTest(_fixtures.FixtureTest): users, ) - class Bar(object): + class Bar: @validates("id") def validate_three(self, key, value): return value + 10 diff --git a/test/sql/test_compare.py b/test/sql/test_compare.py index 5258d09b09..814d9a2ad2 100644 --- a/test/sql/test_compare.py +++ b/test/sql/test_compare.py @@ -166,7 +166,7 @@ class MyType3(TypeDecorator): self.arg = arg -class CoreFixtures(object): +class CoreFixtures: # lambdas which return a tuple of ColumnElement objects. # must return at least two objects that should compare differently. # to test more varieties of "difference" additional objects can be added. @@ -1049,7 +1049,7 @@ class CoreFixtures(object): ] -class CacheKeyFixture(object): +class CacheKeyFixture: def _compare_equal(self, a, b, compare_values): a_key = a._generate_cache_key() b_key = b._generate_cache_key() diff --git a/test/sql/test_defaults.py b/test/sql/test_defaults.py index 2011744fbd..f3260f2721 100644 --- a/test/sql/test_defaults.py +++ b/test/sql/test_defaults.py @@ -140,11 +140,11 @@ class DefaultObjectTest(fixtures.TestBase): def fn2(x, y, z=3): pass - class fn3(object): + class fn3: def __init__(self, x, y): pass - class FN4(object): + class FN4: def __call__(self, x, y): pass @@ -170,21 +170,21 @@ class DefaultObjectTest(fixtures.TestBase): fn5 = list - class fn6a(object): + class fn6a: def __init__(self, x): eq_(x, "context") - class fn6b(object): + class fn6b: def __init__(self, x, y=3): eq_(x, "context") - class FN7(object): + class FN7: def __call__(self, x): eq_(x, "context") fn7 = FN7() - class FN8(object): + class FN8: def __call__(self, x, y=3): eq_(x, "context") @@ -396,7 +396,7 @@ class DefaultRoundTripTest(fixtures.TablesTest): use_function_defaults = testing.against("postgresql", "mssql") is_oracle = testing.against("oracle") - class MyClass(object): + class MyClass: @classmethod def gen_default(cls, ctx): return "hi" diff --git a/test/sql/test_delete.py b/test/sql/test_delete.py index 6f7b3f8f5d..45ead811fc 100644 --- a/test/sql/test_delete.py +++ b/test/sql/test_delete.py @@ -21,7 +21,7 @@ from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table -class _DeleteTestBase(object): +class _DeleteTestBase: @classmethod def define_tables(cls, metadata): Table( diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index 46c526c4b0..89938ee5e1 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -1811,7 +1811,7 @@ class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL): def test_new_calling_style_thing_ok_actually_use_iter(self, table_fixture): table1, table2 = table_fixture - class Thing(object): + class Thing: def __iter__(self): return iter([table1.c.name, table1.c.description]) diff --git a/test/sql/test_insert.py b/test/sql/test_insert.py index 51045daac2..74a60bd215 100644 --- a/test/sql/test_insert.py +++ b/test/sql/test_insert.py @@ -28,7 +28,7 @@ from sqlalchemy.testing import expect_warnings from sqlalchemy.testing import fixtures -class ORMExpr(object): +class ORMExpr: def __init__(self, col): self.col = col @@ -36,7 +36,7 @@ class ORMExpr(object): return self.col -class _InsertTestBase(object): +class _InsertTestBase: @classmethod def define_tables(cls, metadata): Table( diff --git a/test/sql/test_lambdas.py b/test/sql/test_lambdas.py index a2aa9705cb..fd6b1eb41d 100644 --- a/test/sql/test_lambdas.py +++ b/test/sql/test_lambdas.py @@ -689,7 +689,7 @@ class LambdaElementTest( # refer to unknown types of objects inside the lambda. these have # to be resolved outside of the lambda because we otherwise can't # be sure they can be safely used as cache keys. - class Thing(object): + class Thing: def __init__(self, col_expr): self.col_expr = col_expr @@ -713,7 +713,7 @@ class LambdaElementTest( # refer to unknown types of objects inside the lambda. these have # to be resolved outside of the lambda because we otherwise can't # be sure they can be safely used as cache keys. - class Thing(object): + class Thing: def __init__(self, col_expr): self.col_expr = col_expr @@ -765,7 +765,7 @@ class LambdaElementTest( # test the above 'test_reject_plain_object' with the expected # workaround - class Thing(object): + class Thing: def __init__(self, col_expr): self.col_expr = col_expr @@ -1662,7 +1662,7 @@ class LambdaElementTest( def test_cache_key_instance_variable_issue_incorrect(self): t1 = table("t1", column("q"), column("p")) - class Foo(object): + class Foo: def __init__(self, value): self.value = value @@ -1681,7 +1681,7 @@ class LambdaElementTest( def test_cache_key_instance_variable_issue_correct_one(self): t1 = table("t1", column("q"), column("p")) - class Foo(object): + class Foo: def __init__(self, value): self.value = value @@ -1701,7 +1701,7 @@ class LambdaElementTest( def test_cache_key_instance_variable_issue_correct_two(self): t1 = table("t1", column("q"), column("p")) - class Foo(object): + class Foo: def __init__(self, value): self.value = value diff --git a/test/sql/test_metadata.py b/test/sql/test_metadata.py index bd92136479..e87063a907 100644 --- a/test/sql/test_metadata.py +++ b/test/sql/test_metadata.py @@ -354,7 +354,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): ) def test_fk_given_non_col_clauseelem(self): - class Foo(object): + class Foo: def __clause_element__(self): return bindparam("x") @@ -379,7 +379,7 @@ class MetaDataTest(fixtures.TestBase, ComparesTables): def test_fk_given_col_non_table_clauseelem(self): t = Table("t", MetaData(), Column("x", Integer)) - class Foo(object): + class Foo: def __clause_element__(self): return t.alias().c.x @@ -2072,7 +2072,7 @@ class PKAutoIncrementTest(fixtures.TestBase): class SchemaTypeTest(fixtures.TestBase): __backend__ = True - class TrackEvents(object): + class TrackEvents: column = None table = None evt_targets = () @@ -2961,7 +2961,7 @@ class ConstraintTest(fixtures.TestBase): def test_clauseelement_extraction_one(self): t = Table("t", MetaData(), Column("x", Integer), Column("y", Integer)) - class MyThing(object): + class MyThing: def __clause_element__(self): return t.c.x + 5 @@ -2971,7 +2971,7 @@ class ConstraintTest(fixtures.TestBase): def test_clauseelement_extraction_two(self): t = Table("t", MetaData(), Column("x", Integer), Column("y", Integer)) - class MyThing(object): + class MyThing: def __clause_element__(self): return t.c.x + 5 @@ -2984,7 +2984,7 @@ class ConstraintTest(fixtures.TestBase): expr1 = t.c.x + 5 - class MyThing(object): + class MyThing: def __clause_element__(self): return expr1 @@ -3332,7 +3332,7 @@ class ConstraintTest(fixtures.TestBase): def test_column_accessor_clause_element(self): c1 = Column("x", Integer) - class CThing(object): + class CThing: def __init__(self, c): self.c = c @@ -3743,7 +3743,7 @@ class ConstraintTest(fixtures.TestBase): m = MetaData() t2 = Table("t2", m, Column("x", Integer)) - class SomeClass(object): + class SomeClass: def __clause_element__(self): return t2 @@ -3758,7 +3758,7 @@ class ConstraintTest(fixtures.TestBase): @testing.fixture def no_pickle_annotated(self): - class NoPickle(object): + class NoPickle: def __reduce__(self): raise NotImplementedError() diff --git a/test/sql/test_operators.py b/test/sql/test_operators.py index 45ea305481..b86e8d075a 100644 --- a/test/sql/test_operators.py +++ b/test/sql/test_operators.py @@ -449,7 +449,7 @@ class CustomUnaryOperatorTest(fixtures.TestBase, testing.AssertsCompiledSQL): ) -class _CustomComparatorTests(object): +class _CustomComparatorTests: def test_override_builtin(self): c1 = Column("foo", self._add_override_factory()) self._assert_add_override(c1) @@ -2126,7 +2126,7 @@ class InTest(fixtures.TestBase, testing.AssertsCompiledSQL): ) def test_in_arbitrary_sequence(self): - class MySeq(object): + class MySeq: def __init__(self, d): self.d = d diff --git a/test/sql/test_resultset.py b/test/sql/test_resultset.py index cdc314e2f5..9d4e14517e 100644 --- a/test/sql/test_resultset.py +++ b/test/sql/test_resultset.py @@ -359,7 +359,7 @@ class CursorResultTest(fixtures.TablesTest): result = connection.execute(select(1)) row = result.first() - class unprintable(object): + class unprintable: def __str__(self): raise ValueError("nope") @@ -1410,7 +1410,7 @@ class CursorResultTest(fixtures.TablesTest): """ - class MyList(object): + class MyList: def __init__(self, data): self.internal_list = data @@ -2885,7 +2885,7 @@ class AlternateCursorResultTest(fixtures.TablesTest): argnames="method_name", ) def test_handle_error_in_fetch(self, strategy_cls, method_name): - class cursor(object): + class cursor: def raise_(self): raise IOError("random non-DBAPI error during cursor operation") diff --git a/test/sql/test_roles.py b/test/sql/test_roles.py index ff4f10f1ac..abbef8e280 100644 --- a/test/sql/test_roles.py +++ b/test/sql/test_roles.py @@ -41,7 +41,7 @@ m = MetaData() t = Table("t", m, Column("q", Integer)) -class NotAThing1(object): +class NotAThing1: pass @@ -55,7 +55,7 @@ class NotAThing2(ClauseElement): not_a_thing2 = NotAThing2() -class NotAThing3(object): +class NotAThing3: def __clause_element__(self): return not_a_thing2 @@ -215,7 +215,7 @@ class RoleTest(fixtures.TestBase): def some_function(): pass - class Thing(object): + class Thing: def __clause_element__(self): return some_function diff --git a/test/sql/test_select.py b/test/sql/test_select.py index c9abb7fb8b..f79d95a650 100644 --- a/test/sql/test_select.py +++ b/test/sql/test_select.py @@ -67,7 +67,7 @@ class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_new_calling_style_clauseelement_thing_that_has_iter(self): - class Thing(object): + class Thing: def __clause_element__(self): return table1 @@ -82,11 +82,11 @@ class FutureSelectTest(fixtures.TestBase, AssertsCompiledSQL): ) def test_new_calling_style_inspectable_ce_thing_that_has_iter(self): - class Thing(object): + class Thing: def __iter__(self): return iter(["a", "b", "c"]) - class InspectedThing(object): + class InspectedThing: def __clause_element__(self): return table1 diff --git a/test/sql/test_type_expressions.py b/test/sql/test_type_expressions.py index e0e0858a45..cab4f63711 100644 --- a/test/sql/test_type_expressions.py +++ b/test/sql/test_type_expressions.py @@ -14,7 +14,7 @@ from sqlalchemy.testing import eq_ from sqlalchemy.testing import fixtures -class _ExprFixture(object): +class _ExprFixture: def _test_table(self, type_): test_table = Table( "test_table", MetaData(), Column("x", String), Column("y", type_) @@ -363,7 +363,7 @@ class DerivedTest(_ExprFixture, fixtures.TestBase, AssertsCompiledSQL): ) -class RoundTripTestBase(object): +class RoundTripTestBase: def test_round_trip(self, connection): connection.execute( self.tables.test_table.insert(), diff --git a/test/sql/test_types.py b/test/sql/test_types.py index d57603622d..0891defc29 100644 --- a/test/sql/test_types.py +++ b/test/sql/test_types.py @@ -473,7 +473,7 @@ class PickleTypesTest(fixtures.TestBase): loads(dumps(meta)) -class _UserDefinedTypeFixture(object): +class _UserDefinedTypeFixture: @classmethod def define_tables(cls, metadata): class MyType(types.UserDefinedType): @@ -1064,7 +1064,7 @@ class TypeCoerceCastTest(fixtures.TablesTest): # test coerce from nulltype - e.g. use an object that # doesn't match to a known type - class MyObj(object): + class MyObj: def __str__(self): return "THISISMYOBJ" @@ -1190,7 +1190,7 @@ class TypeCoerceCastTest(fixtures.TablesTest): t = self.tables.t conn.execute(t.insert().values(data=coerce_fn("d1", MyType))) - class MyFoob(object): + class MyFoob: def __clause_element__(self): return t.c.data @@ -2323,7 +2323,7 @@ class EnumTest(AssertsCompiledSQL, fixtures.TablesTest): m1.create_all(testing.db) def test_non_native_constraint_custom_type(self): - class Foob(object): + class Foob: def __init__(self, name): self.name = name @@ -3202,7 +3202,7 @@ class ExpressionTest( class MyFoobarType(types.UserDefinedType): pass - class Foo(object): + class Foo: pass # unknown type + integer, right hand bind @@ -3315,11 +3315,11 @@ class ExpressionTest( def test_detect_coercion_of_builtins(self): @inspection._self_inspects - class SomeSQLAThing(object): + class SomeSQLAThing: def __repr__(self): return "some_sqla_thing()" - class SomeOtherThing(object): + class SomeOtherThing: pass assert_raises_message( @@ -3629,7 +3629,7 @@ class BooleanTest( ) def test_non_native_constraint_custom_type(self): - class Foob(object): + class Foob: def __init__(self, value): self.value = value diff --git a/test/sql/test_update.py b/test/sql/test_update.py index 93deae5565..f59f02a7b1 100644 --- a/test/sql/test_update.py +++ b/test/sql/test_update.py @@ -31,7 +31,7 @@ from sqlalchemy.testing.schema import Column from sqlalchemy.testing.schema import Table -class _UpdateFromTestBase(object): +class _UpdateFromTestBase: @classmethod def define_tables(cls, metadata): Table( @@ -128,7 +128,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): def test_update_custom_key_thing(self): table1 = self.tables.mytable - class Thing(object): + class Thing: def __clause_element__(self): return table1.c.name @@ -147,7 +147,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): def test_update_ordered_custom_key_thing(self): table1 = self.tables.mytable - class Thing(object): + class Thing: def __clause_element__(self): return table1.c.name @@ -166,7 +166,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): def test_update_broken_custom_key_thing(self): table1 = self.tables.mytable - class Thing(object): + class Thing: def __clause_element__(self): return 5 @@ -180,7 +180,7 @@ class UpdateTest(_UpdateFromTestBase, fixtures.TablesTest, AssertsCompiledSQL): def test_update_ordered_broken_custom_key_thing(self): table1 = self.tables.mytable - class Thing(object): + class Thing: def __clause_element__(self): return 5 diff --git a/test/sql/test_values.py b/test/sql/test_values.py index dcd32a6791..f5ae9ea53d 100644 --- a/test/sql/test_values.py +++ b/test/sql/test_values.py @@ -168,7 +168,7 @@ class ValuesTest(fixtures.TablesTest, AssertsCompiledSQL): @testing.fixture def tricky_types_parameter_fixture(self): - class SomeEnum(object): + class SomeEnum: # Implements PEP 435 in the minimal fashion needed by SQLAlchemy __members__ = OrderedDict()