# Buggy code
def __init__(self, *enums, **kw):
    """Construct an :class:`_postgresql.ENUM`.

    Arguments are the same as that of
    :class:`_types.Enum`, but also including
    the following parameters.

    :param create_type: Defaults to True.
     Indicates that ``CREATE TYPE`` should be
     emitted, after optionally checking for the
     presence of the type, when the parent
     table is being created; and additionally
     that ``DROP TYPE`` is called when the table
     is dropped.    When ``False``, no check
     will be performed and no ``CREATE TYPE``
     or ``DROP TYPE`` is emitted, unless
     :meth:`~.postgresql.ENUM.create`
     or :meth:`~.postgresql.ENUM.drop`
     are called directly.
     Setting to ``False`` is helpful
     when invoking a creation scheme to a SQL file
     without access to the actual database -
     the :meth:`~.postgresql.ENUM.create` and
     :meth:`~.postgresql.ENUM.drop` methods can
     be used to emit SQL to a target bind.

    """
    self.create_type = kw.pop("create_type", True)
    super(ENUM, self).__init__(*enums, **kw)


# Traceback (sqlalchemy.exc.ProgrammingError)
Traceback (most recent call last):
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
self.dialect.do_execute(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
cursor.execute(statement, parameters)
psycopg2.errors.DuplicateObject: type "mood" already exists


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/robert_muil/Library/Application Support/JetBrains/PyCharm2020.2/scratches/scratch_9.py", line 51, in <module>
raise ex
File "/Users/robert_muil/Library/Application Support/JetBrains/PyCharm2020.2/scratches/scratch_9.py", line 48, in <module>
Base.metadata.create_all(bind=conn)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/sql/schema.py", line 4546, in create_all
bind._run_visitor(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1657, in _run_visitor
visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py", line 144, in traverse_single
return meth(obj, **kw)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/sql/ddl.py", line 783, in visit_metadata
self.traverse_single(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/sql/visitors.py", line 144, in traverse_single
return meth(obj, **kw)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/sql/ddl.py", line 811, in visit_table
table.dispatch.before_create(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/event/attr.py", line 322, in __call__
fn(*args, **kw)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/util/langhelpers.py", line 645, in __call__
return getattr(self.target, self.name)(*arg, **kw)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/base.py", line 1575, in _on_table_create
self.create(bind=bind, checkfirst=checkfirst)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/dialects/postgresql/base.py", line 1510, in create
bind.execute(CreateEnumType(self))
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1014, in execute
return meth(self, multiparams, params)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/sql/ddl.py", line 72, in _execute_on_connection
return connection._execute_ddl(self, multiparams, params)
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1071, in _execute_ddl
ret = self._execute_context(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
self._handle_dbapi_exception(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
util.raise_(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
raise exception
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
self.dialect.do_execute(
File "/usr/local/anaconda3/envs/datacat/lib/python3.8/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateObject) type "mood" already exists

[SQL: CREATE TYPE minimal_failing_example.mood AS ENUM ('sad', 'ok', 'happy')]
(Background on this error at: http://sqlalche.me/e/13/f405)

# Fixed code
def __init__(self, dialect, connection, checkfirst=False, **kwargs):
    super(ENUM.EnumDropper, self).__init__(connection, **kwargs)
    self.checkfirst = checkfirst