Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AURA
steering
Commits
5bd89e8a
Verified
Commit
5bd89e8a
authored
9 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
refactor: extract TypeDict annotations into typing module
parent
82f776f5
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
program/serializers.py
+11
-69
11 additions, 69 deletions
program/serializers.py
program/typing.py
+68
-1
68 additions, 1 deletion
program/typing.py
with
79 additions
and
70 deletions
program/serializers.py
+
11
−
69
View file @
5bd89e8a
...
...
@@ -19,7 +19,6 @@
#
import
re
from
typing
import
Literal
,
NotRequired
,
TypedDict
from
drf_jsonschema_serializer
import
JSONSchemaField
from
rest_framework
import
serializers
...
...
@@ -52,7 +51,17 @@ from program.models import (
Type
,
UserProfile
,
)
from
program.typing
import
NestedEpisode
,
NestedSchedule
,
NestedShow
from
program.typing
import
(
Logo
,
NestedEpisode
,
NestedSchedule
,
NestedShow
,
RadioCBASettings
,
RadioImageRequirementsSettings
,
RadioPlayoutSettings
,
RadioProgramSettings
,
RadioStationSettings
,
)
from
program.utils
import
update_links
SOLUTION_CHOICES
=
{
...
...
@@ -278,12 +287,6 @@ class PPOIField(serializers.CharField):
return
f
"
{
left
}
x
{
top
}
"
class
Thumbnail
(
TypedDict
):
width
:
float
height
:
float
url
:
str
class
ImageSerializer
(
serializers
.
ModelSerializer
):
license_id
=
serializers
.
PrimaryKeyRelatedField
(
allow_null
=
True
,
...
...
@@ -1174,67 +1177,6 @@ class NoteSerializer(serializers.ModelSerializer):
return
instance
class
RadioCBASettings
(
TypedDict
):
api_key
:
NotRequired
[
str
]
domains
:
list
[
str
]
class
ProgramFallback
(
TypedDict
):
default_pool
:
str
show_id
:
int
|
None
class
MicroProgram
(
TypedDict
):
show_id
:
int
|
None
class
RadioProgramSettings
(
TypedDict
):
fallback
:
ProgramFallback
micro
:
MicroProgram
class
PlayoutPools
(
TypedDict
):
fallback
:
str
|
None
class
RadioPlayoutSettings
(
TypedDict
):
line_in_channels
:
dict
[
str
,
str
]
pools
:
PlayoutPools
class
Logo
(
TypedDict
):
url
:
str
height
:
int
width
:
int
class
RadioStationSettings
(
TypedDict
):
name
:
str
logo
:
Logo
|
None
website
:
str
class
ImageFrame
(
TypedDict
):
aspect_ratio
:
tuple
[
int
,
int
]
|
tuple
[
float
,
float
]
shape
:
Literal
[
"
rect
"
,
"
round
"
]
class
ImageRequirements
(
TypedDict
):
frame
:
ImageFrame
# done this way, because the keys have dots (".")
RadioImageRequirementsSettings
=
TypedDict
(
"
RadioImageRequirementsSettings
"
,
{
"
host.image
"
:
ImageRequirements
,
"
note.image
"
:
ImageRequirements
,
"
show.image
"
:
ImageRequirements
,
"
show.logo
"
:
ImageRequirements
,
},
)
class
RadioSettingsSerializer
(
serializers
.
ModelSerializer
):
cba
=
serializers
.
SerializerMethodField
()
image_requirements
=
serializers
.
SerializerMethodField
()
...
...
This diff is collapsed.
Click to expand it.
program/typing.py
+
68
−
1
View file @
5bd89e8a
from
typing
import
TypedDict
from
typing
import
Literal
,
NotRequired
,
TypedDict
class
NestedTimeslot
(
TypedDict
):
...
...
@@ -38,3 +38,70 @@ class TimerangeEntry(TypedDict):
schedule
:
NestedSchedule
|
None
show
:
NestedShow
timeslot
:
NestedTimeslot
class
Thumbnail
(
TypedDict
):
width
:
float
height
:
float
url
:
str
class
RadioCBASettings
(
TypedDict
):
api_key
:
NotRequired
[
str
]
domains
:
list
[
str
]
class
ProgramFallback
(
TypedDict
):
default_pool
:
str
show_id
:
int
|
None
class
MicroProgram
(
TypedDict
):
show_id
:
int
|
None
class
RadioProgramSettings
(
TypedDict
):
fallback
:
ProgramFallback
micro
:
MicroProgram
class
PlayoutPools
(
TypedDict
):
fallback
:
str
|
None
class
RadioPlayoutSettings
(
TypedDict
):
line_in_channels
:
dict
[
str
,
str
]
pools
:
PlayoutPools
class
Logo
(
TypedDict
):
url
:
str
height
:
int
width
:
int
class
RadioStationSettings
(
TypedDict
):
name
:
str
logo
:
Logo
|
None
website
:
str
class
ImageFrame
(
TypedDict
):
aspect_ratio
:
tuple
[
int
,
int
]
|
tuple
[
float
,
float
]
shape
:
Literal
[
"
rect
"
,
"
round
"
]
class
ImageRequirements
(
TypedDict
):
frame
:
ImageFrame
# done this way, because the keys have dots (".")
RadioImageRequirementsSettings
=
TypedDict
(
"
RadioImageRequirementsSettings
"
,
{
"
host.image
"
:
ImageRequirements
,
"
note.image
"
:
ImageRequirements
,
"
show.image
"
:
ImageRequirements
,
"
show.logo
"
:
ImageRequirements
,
},
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment