lint: reformat python code with black

This commit is contained in:
Iain Learmonth 2024-12-06 18:15:47 +00:00
parent 331beb01b4
commit a406a7974b
88 changed files with 2579 additions and 1608 deletions

View file

@ -26,17 +26,21 @@ class Group(AbstractConfiguration):
eotk: Mapped[bool]
origins: Mapped[List["Origin"]] = relationship("Origin", back_populates="group")
statics: Mapped[List["StaticOrigin"]] = relationship("StaticOrigin", back_populates="group")
statics: Mapped[List["StaticOrigin"]] = relationship(
"StaticOrigin", back_populates="group"
)
eotks: Mapped[List["Eotk"]] = relationship("Eotk", back_populates="group")
onions: Mapped[List["Onion"]] = relationship("Onion", back_populates="group")
smart_proxies: Mapped[List["SmartProxy"]] = relationship("SmartProxy", back_populates="group")
pools: Mapped[List["Pool"]] = relationship("Pool", secondary="pool_group", back_populates="groups")
smart_proxies: Mapped[List["SmartProxy"]] = relationship(
"SmartProxy", back_populates="group"
)
pools: Mapped[List["Pool"]] = relationship(
"Pool", secondary="pool_group", back_populates="groups"
)
@classmethod
def csv_header(cls) -> List[str]:
return super().csv_header() + [
"group_name", "eotk"
]
return super().csv_header() + ["group_name", "eotk"]
@property
def brn(self) -> BRN:
@ -45,16 +49,15 @@ class Group(AbstractConfiguration):
product="group",
provider="",
resource_type="group",
resource_id=str(self.id)
resource_id=str(self.id),
)
def to_dict(self) -> GroupDict:
if not TYPE_CHECKING:
from app.models.mirrors import Origin # to prevent circular import
active_origins_query = (
db.session.query(aliased(Origin))
.filter(and_(Origin.group_id == self.id, Origin.destroyed.is_(None)))
active_origins_query = db.session.query(aliased(Origin)).filter(
and_(Origin.group_id == self.id, Origin.destroyed.is_(None))
)
active_origins_count = active_origins_query.count()
return {
@ -70,16 +73,20 @@ class Pool(AbstractConfiguration):
api_key: Mapped[str]
redirector_domain: Mapped[Optional[str]]
bridgeconfs: Mapped[List["BridgeConf"]] = relationship("BridgeConf", back_populates="pool")
bridgeconfs: Mapped[List["BridgeConf"]] = relationship(
"BridgeConf", back_populates="pool"
)
proxies: Mapped[List["Proxy"]] = relationship("Proxy", back_populates="pool")
lists: Mapped[List["MirrorList"]] = relationship("MirrorList", back_populates="pool")
groups: Mapped[List[Group]] = relationship("Group", secondary="pool_group", back_populates="pools")
lists: Mapped[List["MirrorList"]] = relationship(
"MirrorList", back_populates="pool"
)
groups: Mapped[List[Group]] = relationship(
"Group", secondary="pool_group", back_populates="pools"
)
@classmethod
def csv_header(cls) -> List[str]:
return super().csv_header() + [
"pool_name"
]
return super().csv_header() + ["pool_name"]
@property
def brn(self) -> BRN:
@ -88,7 +95,7 @@ class Pool(AbstractConfiguration):
product="pool",
provider="",
resource_type="pool",
resource_id=str(self.pool_name)
resource_id=str(self.pool_name),
)
@ -121,14 +128,14 @@ class MirrorList(AbstractConfiguration):
"bc3": "Bypass Censorship v3",
"bca": "Bypass Censorship Analytics",
"bridgelines": "Tor Bridge Lines",
"rdr": "Redirector Data"
"rdr": "Redirector Data",
}
encodings_supported = {
"json": "JSON (Plain)",
"jsno": "JSON (Obfuscated)",
"js": "JavaScript (Plain)",
"jso": "JavaScript (Obfuscated)"
"jso": "JavaScript (Obfuscated)",
}
def destroy(self) -> None:
@ -149,7 +156,11 @@ class MirrorList(AbstractConfiguration):
@classmethod
def csv_header(cls) -> List[str]:
return super().csv_header() + [
"provider", "format", "container", "branch", "filename"
"provider",
"format",
"container",
"branch",
"filename",
]
@property
@ -159,5 +170,5 @@ class MirrorList(AbstractConfiguration):
product="list",
provider=self.provider,
resource_type="list",
resource_id=str(self.id)
resource_id=str(self.id),
)