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
0b976c7a
Verified
Commit
0b976c7a
authored
8 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
refactor: move remaining uses of TypedDict -> typing module
parent
ee259657
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
program/services.py
+3
-52
3 additions, 52 deletions
program/services.py
program/typing.py
+56
-0
56 additions, 0 deletions
program/typing.py
program/utils.py
+2
-6
2 additions, 6 deletions
program/utils.py
with
61 additions
and
58 deletions
program/services.py
+
3
−
52
View file @
0b976c7a
...
...
@@ -20,7 +20,6 @@
import
copy
from
datetime
import
datetime
,
time
,
timedelta
from
itertools
import
pairwise
from
typing
import
TypedDict
from
dateutil.relativedelta
import
relativedelta
from
dateutil.rrule
import
rrule
...
...
@@ -42,67 +41,19 @@ from program.models import (
)
from
program.serializers
import
ScheduleSerializer
,
TimeSlotSerializer
from
program.typing
import
(
Conflicts
,
DayScheduleEntry
,
NestedEpisode
,
NestedSchedule
,
NestedShow
,
NestedTimeslot
,
ScheduleCreateUpdateData
,
ScheduleData
,
TimerangeEntry
,
)
from
program.utils
import
parse_date
,
parse_datetime
,
parse_time
class
ScheduleData
(
TypedDict
):
add_business_days_only
:
bool
|
None
add_days_no
:
int
|
None
by_weekday
:
int
|
None
default_playlist_id
:
int
|
None
dryrun
:
bool
|
None
end_time
:
str
first_date
:
str
id
:
int
|
None
is_repetition
:
bool
|
None
last_date
:
str
|
None
rrule_id
:
int
show_id
:
int
|
None
start_time
:
str
class
Collision
(
TypedDict
):
end
:
str
timeslot_id
:
int
memo
:
str
note_id
:
int
|
None
playlist_id
:
int
|
None
schedule_id
:
int
show_id
:
int
show_name
:
str
start
:
str
class
ProjectedEntry
(
TypedDict
):
collisions
:
list
[
Collision
]
end
:
str
error
:
str
|
None
hash
:
str
solution_choices
:
set
[
str
]
start
:
str
class
Conflicts
(
TypedDict
):
notes
:
dict
playlists
:
dict
projected
:
list
[
ProjectedEntry
]
solutions
:
dict
[
str
,
str
]
class
ScheduleCreateUpdateData
(
TypedDict
):
notes
:
dict
playlists
:
dict
schedule
:
ScheduleData
solutions
:
dict
[
str
,
str
]
def
create_timeslot
(
start
:
str
,
end
:
str
,
schedule
:
Schedule
)
->
TimeSlot
:
"""
Creates and returns an unsaved timeslot with the given `start`, `end` and `schedule`.
"""
...
...
This diff is collapsed.
Click to expand it.
program/typing.py
+
56
−
0
View file @
0b976c7a
...
...
@@ -105,3 +105,59 @@ RadioImageRequirementsSettings = TypedDict(
"
show.logo
"
:
ImageRequirements
,
},
)
class
Link
(
TypedDict
):
type_id
:
int
url
:
str
class
ScheduleData
(
TypedDict
):
add_business_days_only
:
bool
|
None
add_days_no
:
int
|
None
by_weekday
:
int
|
None
default_playlist_id
:
int
|
None
dryrun
:
bool
|
None
end_time
:
str
first_date
:
str
id
:
int
|
None
is_repetition
:
bool
|
None
last_date
:
str
|
None
rrule_id
:
int
show_id
:
int
|
None
start_time
:
str
class
Collision
(
TypedDict
):
end
:
str
timeslot_id
:
int
memo
:
str
note_id
:
int
|
None
playlist_id
:
int
|
None
schedule_id
:
int
show_id
:
int
show_name
:
str
start
:
str
class
ProjectedEntry
(
TypedDict
):
collisions
:
list
[
Collision
]
end
:
str
error
:
str
|
None
hash
:
str
solution_choices
:
set
[
str
]
start
:
str
class
Conflicts
(
TypedDict
):
notes
:
dict
playlists
:
dict
projected
:
list
[
ProjectedEntry
]
solutions
:
dict
[
str
,
str
]
class
ScheduleCreateUpdateData
(
TypedDict
):
notes
:
dict
playlists
:
dict
schedule
:
ScheduleData
solutions
:
dict
[
str
,
str
]
This diff is collapsed.
Click to expand it.
program/utils.py
+
2
−
6
View file @
0b976c7a
...
...
@@ -21,12 +21,13 @@
import
json
import
typing
from
datetime
import
date
,
datetime
,
time
from
typing
import
Dict
,
Optional
,
Tuple
,
TypedDict
,
Union
from
typing
import
Dict
,
Optional
,
Tuple
,
Union
import
requests
from
django.conf
import
settings
from
django.utils
import
timezone
from
program.typing
import
Link
if
typing
.
TYPE_CHECKING
:
from
program.models
import
Host
,
HostLink
,
Note
,
NoteLink
,
Show
,
ShowLink
...
...
@@ -34,11 +35,6 @@ else:
from
program.models
import
Host
,
HostLink
,
Note
,
NoteLink
,
Show
,
ShowLink
class
Link
(
TypedDict
):
type_id
:
int
url
:
str
def
parse_datetime
(
date_string
:
str
|
None
)
->
datetime
|
None
:
"""
parse a datetime string and return a timezone aware datetime object.
...
...
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