Skip to content

Commit 954a9ba

Browse files
Merge pull request #96 from codecov/scott/github-pr-labels
GitHub PR labels, SQLAlchemy version
2 parents a9399a1 + e8cb0e4 commit 954a9ba

File tree

5 files changed

+19
-18
lines changed

5 files changed

+19
-18
lines changed

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"pyjwt",
4848
"pytz",
4949
"django>=4.2.3",
50-
"sqlalchemy>=2.0",
50+
"sqlalchemy==1.*",
5151
"ijson==3.*",
5252
],
5353
)

shared/bundle_analysis/models.py

+7-15
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
from typing import List
33

44
from sqlalchemy import Column, ForeignKey, Table, create_engine, types
5-
from sqlalchemy.orm import Mapped
5+
from sqlalchemy.ext.declarative import declarative_base
66
from sqlalchemy.orm import Session as DbSession
7-
from sqlalchemy.orm import backref, declarative_base, relationship, sessionmaker
7+
from sqlalchemy.orm import backref, relationship, sessionmaker
88

99
SCHEMA = """
1010
create table sessions (
@@ -131,10 +131,8 @@ class Asset(Base):
131131
normalized_name = Column(types.Text, nullable=False)
132132
size = Column(types.Integer, nullable=False)
133133

134-
session = relationship(Session, backref=backref("assets"))
135-
chunks: Mapped[List["Chunk"]] = relationship(
136-
secondary=assets_chunks, back_populates="assets"
137-
)
134+
session = relationship("Session", backref=backref("assets"))
135+
chunks = relationship("Chunk", secondary=assets_chunks, back_populates="assets")
138136

139137

140138
class Chunk(Base):
@@ -150,12 +148,8 @@ class Chunk(Base):
150148
entry = Column(types.Boolean, nullable=False)
151149
initial = Column(types.Boolean, nullable=False)
152150

153-
assets: Mapped[List["Asset"]] = relationship(
154-
secondary=assets_chunks, back_populates="chunks"
155-
)
156-
modules: Mapped[List["Module"]] = relationship(
157-
secondary=chunks_modules, back_populates="chunks"
158-
)
151+
assets = relationship("Asset", secondary=assets_chunks, back_populates="chunks")
152+
modules = relationship("Module", secondary=chunks_modules, back_populates="chunks")
159153

160154

161155
class Module(Base):
@@ -169,9 +163,7 @@ class Module(Base):
169163
name = Column(types.Text, nullable=False)
170164
size = Column(types.Integer, nullable=False)
171165

172-
chunks: Mapped[List["Chunk"]] = relationship(
173-
secondary=chunks_modules, back_populates="modules"
174-
)
166+
chunks = relationship("Chunk", secondary=chunks_modules, back_populates="modules")
175167

176168

177169
class MetadataKey(Enum):

shared/torngit/github.py

+1
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,7 @@ def _pull(self, pull):
11411141
title=pull["title"],
11421142
id=str(pull["number"]),
11431143
number=str(pull["number"]),
1144+
labels=[label["name"] for label in pull.get("labels", [])],
11441145
)
11451146

11461147
async def get_pull_request(self, pullid, token=None):

shared/validation/user_schema.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,11 @@
490490
},
491491
"beta_groups": {"type": "list", "schema": {"type": "string"}},
492492
"ai_pr_review": {
493-
"type": ["dict", "boolean"],
494-
"schema": {"enabled": {"type": "boolean"}},
493+
"type": ["dict"],
494+
"schema": {
495+
"enabled": {"type": "boolean"},
496+
"method": {"type": "string"},
497+
"label_name": {"type": "string"},
498+
},
495499
},
496500
}

tests/integration/test_github.py

+4
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ async def test_get_pull_request_fail(
270270
"state": "merged",
271271
"title": "Creating new code for reasons no one knows",
272272
"author": {"id": "44376991", "username": "ThiagoCodecov"},
273+
"labels": [],
273274
},
274275
)
275276
]
@@ -293,6 +294,7 @@ async def test_get_pull_request_way_more_than_250_results(
293294
"state": "open",
294295
"title": "PR with more than 250 results",
295296
"author": {"id": "44376991", "username": "ThiagoCodecov"},
297+
"labels": [],
296298
}
297299
res = await valid_handler.get_pull_request(pull_id)
298300
assert res == expected_result
@@ -1182,6 +1184,7 @@ async def test_get_pull_request_base_doesnt_match(self, valid_handler, codecov_v
11821184
"state": "closed",
11831185
"title": "Thiago/test 1",
11841186
"author": {"id": "44376991", "username": "ThiagoCodecov"},
1187+
"labels": [],
11851188
}
11861189
res = await valid_handler.get_pull_request(pull_id)
11871190
assert res == expected_result
@@ -1210,6 +1213,7 @@ async def test_get_pull_request_base_partially_differs(
12101213
"state": "merged",
12111214
"title": "CE-1314 GitHub Status Event Handler",
12121215
"author": {"id": "5767537", "username": "pierce-m"},
1216+
"labels": [],
12131217
}
12141218
res = await handler.get_pull_request(pull_id)
12151219
assert res == expected_result

0 commit comments

Comments
 (0)