import enum

from sqlalchemy import Column, String, Boolean, Integer, DateTime, Enum

from virtool.postgres import Base


class UploadType(enum.Enum):
    hmm = "hmm"
    reference = "reference"
    reads = "reads"
    subtraction = "subtraction"
    null = None


class Upload(Base):
    __tablename__ = "uploads"

    id = Column(Integer, primary_key=True)
    created_at = Column(DateTime)
    name = Column(String)
    name_on_disk = Column(String, unique=True)
    ready = Column(Boolean)
    removed = Column(Boolean)
    reserved = Column(Boolean)
    size = Column(Integer)
    type = Column(Enum(UploadType))
    user = Column(String)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return """<Upload(id= {self.id}, created_at={self.created_at}, name={self.name}, \
               name_on_disk={self.name_on_disk}, ready={self.ready}, removed={self.removed}, reserved={self.reserved}, \
               size={self.size}, type={self.type}, user={self.user}, uploaded_at={self.uploaded_at}>"""

import enum

from sqlalchemy import Column, String, Boolean, Integer, DateTime, Enum

from virtool.postgres import Base


class UploadType(str, enum.Enum):
    hmm = "hmm"
    reference = "reference"
    reads = "reads"
    subtraction = "subtraction"
    null = None


class Upload(Base):
    __tablename__ = "uploads"

    id = Column(Integer, primary_key=True)
    created_at = Column(DateTime)
    name = Column(String)
    name_on_disk = Column(String, unique=True)
    ready = Column(Boolean)
    removed = Column(Boolean)
    reserved = Column(Boolean)
    size = Column(Integer)
    type = Column(Enum(UploadType))
    user = Column(String)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<Upload(id={self.id}, created_at={self.created_at}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, ready={self.ready}, removed={self.removed}, " \
               f"reserved={self.reserved}, " f"size={self.size}, type={self.type}, user={self.user}, " \
               f"uploaded_at={self.uploaded_at}>"

Declare subclass of `UploadType` to be `str`
Declare subclass of `UploadType` to be `str`

* Fixes issues with JSON serializing
* Revert `__repr__` string format changes as the newlines created large gaps of whitespace
  import enum
  
  from sqlalchemy import Column, String, Boolean, Integer, DateTime, Enum
  
  from virtool.postgres import Base
  
  
- class UploadType(enum.Enum):
+ class UploadType(str, enum.Enum):
      hmm = "hmm"
      reference = "reference"
      reads = "reads"
      subtraction = "subtraction"
      null = None
  
  
  class Upload(Base):
      __tablename__ = "uploads"
  
      id = Column(Integer, primary_key=True)
      created_at = Column(DateTime)
      name = Column(String)
      name_on_disk = Column(String, unique=True)
      ready = Column(Boolean)
      removed = Column(Boolean)
      reserved = Column(Boolean)
      size = Column(Integer)
      type = Column(Enum(UploadType))
      user = Column(String)
      uploaded_at = Column(DateTime)
  
      def __repr__(self):
-         return """<Upload(id= {self.id}, created_at={self.created_at}, name={self.name}, \
+         return f"<Upload(id={self.id}, created_at={self.created_at}, name={self.name}, " \
-                name_on_disk={self.name_on_disk}, ready={self.ready}, removed={self.removed}, reserved={self.reserved}, \
+                f"name_on_disk={self.name_on_disk}, ready={self.ready}, removed={self.removed}, " \
-                size={self.size}, type={self.type}, user={self.user}, uploaded_at={self.uploaded_at}>"""
+                f"reserved={self.reserved}, " f"size={self.size}, type={self.type}, user={self.user}, " \
+                f"uploaded_at={self.uploaded_at}>"
  
Declare subclass of `UploadType` to be `str`
## Code Before:
import enum

from sqlalchemy import Column, String, Boolean, Integer, DateTime, Enum

from virtool.postgres import Base


class UploadType(enum.Enum):
    hmm = "hmm"
    reference = "reference"
    reads = "reads"
    subtraction = "subtraction"
    null = None


class Upload(Base):
    __tablename__ = "uploads"

    id = Column(Integer, primary_key=True)
    created_at = Column(DateTime)
    name = Column(String)
    name_on_disk = Column(String, unique=True)
    ready = Column(Boolean)
    removed = Column(Boolean)
    reserved = Column(Boolean)
    size = Column(Integer)
    type = Column(Enum(UploadType))
    user = Column(String)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return """<Upload(id= {self.id}, created_at={self.created_at}, name={self.name}, \
               name_on_disk={self.name_on_disk}, ready={self.ready}, removed={self.removed}, reserved={self.reserved}, \
               size={self.size}, type={self.type}, user={self.user}, uploaded_at={self.uploaded_at}>"""

## Instruction:
Declare subclass of `UploadType` to be `str`
## Code After:
import enum

from sqlalchemy import Column, String, Boolean, Integer, DateTime, Enum

from virtool.postgres import Base


class UploadType(str, enum.Enum):
    hmm = "hmm"
    reference = "reference"
    reads = "reads"
    subtraction = "subtraction"
    null = None


class Upload(Base):
    __tablename__ = "uploads"

    id = Column(Integer, primary_key=True)
    created_at = Column(DateTime)
    name = Column(String)
    name_on_disk = Column(String, unique=True)
    ready = Column(Boolean)
    removed = Column(Boolean)
    reserved = Column(Boolean)
    size = Column(Integer)
    type = Column(Enum(UploadType))
    user = Column(String)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<Upload(id={self.id}, created_at={self.created_at}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, ready={self.ready}, removed={self.removed}, " \
               f"reserved={self.reserved}, " f"size={self.size}, type={self.type}, user={self.user}, " \
               f"uploaded_at={self.uploaded_at}>"
