Skip to content

Commit 9de8c18

Browse files
committed
Run Black and Prettier
1 parent d683365 commit 9de8c18

25 files changed

+190
-180
lines changed

deploy/web_scripts/notify_build.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ def main():
7575
zfh.extractall(OUTPUT_DIR)
7676
success = True
7777
break
78-
return "Fetched artifact successfully" if success else "Could not find artifact among {}: {}".format(len(artifacts), ", ".join(a.get("name") for a in artifacts))
78+
return (
79+
"Fetched artifact successfully"
80+
if success
81+
else "Could not find artifact among {}: {}".format(
82+
len(artifacts), ", ".join(a.get("name") for a in artifacts)
83+
)
84+
)
7985

8086

8187
if __name__ == "__main__":

scrapers/fireroad.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def parse_timeslot(day, slot):
5353
def parse_section(section):
5454
"""Parses a section string.
5555
Example: "32-123/TR/0/11/F/0/2" -> [[[36, 2], [96, 2], [132, 2]], '32-123']
56-
56+
5757
Args:
5858
* section (str): The section given as a string
5959
@@ -89,12 +89,7 @@ def parse_schedule(course):
8989

9090
# Kinds of sections that exist.
9191
result["s"] = []
92-
section_kinds = (
93-
"Lecture",
94-
"Recitation",
95-
"Lab",
96-
"Design"
97-
)
92+
section_kinds = ("Lecture", "Recitation", "Lab", "Design")
9893

9994
for chunk in schedule.split(";"):
10095
name, *sections = chunk.split(",")

scrapers/math_dept.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
course_list = soup.find("ul", {"class": "course-list"})
2323
rows = course_list.findAll("li", recursive=False)
2424

25+
2526
def parse_when(when):
2627
"""
2728
Parses when the class happens.
@@ -46,10 +47,12 @@ def parse_when(when):
4647
times = times.replace(":", ".")
4748
return days, times
4849

50+
4951
assert parse_when("F10:30-12") == ("F", "10.30-12")
5052
assert parse_when("MW1") == ("MW", "1")
5153
assert parse_when("MWF11") == ("MWF", "11")
5254

55+
5356
def parse_many_timeslots(days, times):
5457
"""
5558
Parses many timeslots
@@ -79,6 +82,7 @@ def make_raw_sections(days, times, room):
7982
"""
8083
return f"{room}/{days}/0/{times}"
8184

85+
8286
def make_section_override(timeslots, room):
8387
"""
8488
Makes a section override
@@ -92,7 +96,8 @@ def make_section_override(timeslots, room):
9296
"""
9397
return [[timeslots, room]]
9498
# lol this is wrong
95-
#return [[section, room] for section in timeslots]
99+
# return [[section, room] for section in timeslots]
100+
96101

97102
overrides = {}
98103

@@ -124,7 +129,7 @@ def make_section_override(timeslots, room):
124129
lecture_sections = make_section_override(timeslots, where)
125130
overrides[subject] = {
126131
"lectureRawSections": lecture_raw_sections,
127-
"lectureSections": lecture_sections
132+
"lectureSections": lecture_sections,
128133
}
129134
# Make sure the raw thing that I do not comprehend is actually correct
130135
assert parse_section(lecture_raw_sections) == lecture_sections[0]

scrapers/utils.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* get_term_info()
1616
"""
1717

18-
1918
import itertools
2019
import json
2120

@@ -122,7 +121,7 @@ def zip_strict(*iterables):
122121
sentinel = object()
123122
for tuple in itertools.zip_longest(*iterables, fillvalue=sentinel):
124123
if any(sentinel is t for t in tuple):
125-
raise ValueError('Iterables have different lengths')
124+
raise ValueError("Iterables have different lengths")
126125
yield tuple
127126

128127

src/components/ActivityButtons.tsx

+27-18
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function ToggleButton(
2929
props: ComponentProps<"button"> & {
3030
active: boolean;
3131
handleClick: () => void;
32-
}
32+
},
3333
) {
3434
const { children, active, handleClick, ...otherProps } = props;
3535
return (
@@ -83,15 +83,27 @@ function OverrideLocations(props: { state: State; secs: Sections }) {
8383
const onCancel = () => {
8484
setIsOverriding(false);
8585
};
86-
return isOverriding
87-
? <Flex gap={1} mr = {1} mt = {2}><Input
86+
return isOverriding ? (
87+
<Flex gap={1} mr={1} mt={2}>
88+
<Input
8889
value={room}
89-
onChange={e => setRoom(e.target.value)}
90-
placeholder="26-100" />
91-
<Button onClick={onConfirm}><CheckIcon/></Button>
92-
<Button onClick={onCancel} ><CloseIcon/></Button></Flex>
93-
: (<Flex mt = {2}><Button onClick={onRelocate}>{secs.roomOverride ? "Change" : "Add"} custom location</Button></Flex>);
94-
90+
onChange={(e) => setRoom(e.target.value)}
91+
placeholder="26-100"
92+
/>
93+
<Button onClick={onConfirm}>
94+
<CheckIcon />
95+
</Button>
96+
<Button onClick={onCancel}>
97+
<CloseIcon />
98+
</Button>
99+
</Flex>
100+
) : (
101+
<Flex mt={2}>
102+
<Button onClick={onRelocate}>
103+
{secs.roomOverride ? "Change" : "Add"} custom location
104+
</Button>
105+
</Flex>
106+
);
95107
}
96108

97109
/** Div containing section manual selection interface. */
@@ -157,16 +169,13 @@ function ActivityColor(props: {
157169
setColor(canon);
158170
setInput("");
159171
}
160-
}
172+
};
161173

162174
return (
163175
<Flex gap={2}>
164176
<HexColorPicker color={color} onChange={setColor} />
165177
<Flex direction="column" gap={2}>
166-
<form
167-
onSubmit={handleSubmit}
168-
onBlur={handleSubmit}
169-
>
178+
<form onSubmit={handleSubmit} onBlur={handleSubmit}>
170179
<Input
171180
// Wide enough to hold everything, but keeps buttons below small
172181
width={"12ch"}
@@ -247,7 +256,7 @@ export function ClassButtons(props: { cls: Class; state: State }) {
247256
function NonClassAddTime(props: { activity: NonClass; state: State }) {
248257
const { activity, state } = props;
249258
const [days, setDays] = useState(
250-
Object.fromEntries(WEEKDAY_STRINGS.map((day) => [day, false]))
259+
Object.fromEntries(WEEKDAY_STRINGS.map((day) => [day, false])),
251260
);
252261
const [times, setTimes] = useState({ start: "10:00 AM", end: "1:00 PM" });
253262

@@ -259,8 +268,8 @@ function NonClassAddTime(props: { activity: NonClass; state: State }) {
259268
activity,
260269
Timeslot.fromStartEnd(
261270
Slot.fromDayString(day, times.start),
262-
Slot.fromDayString(day, times.end)
263-
)
271+
Slot.fromDayString(day, times.end),
272+
),
264273
);
265274
}
266275
};
@@ -344,7 +353,7 @@ export function NonClassButtons(props: { activity: NonClass; state: State }) {
344353
</>
345354
);
346355
return [renderHeading, renderButtons];
347-
} else if(isRelocating) {
356+
} else if (isRelocating) {
348357
const renderHeading = () => (
349358
<Input
350359
value={room}

src/components/ActivityDescription.tsx

+12-22
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function TypeSpan(props: { flag?: string; title: string }) {
4343
}
4444

4545
/** Header for class description; contains flags and related classes. */
46-
function ClassTypes(props: { cls: Class, state: State }) {
46+
function ClassTypes(props: { cls: Class; state: State }) {
4747
const { cls, state } = props;
4848
const { flags, totalUnits, units } = cls;
4949

@@ -58,9 +58,10 @@ function ClassTypes(props: { cls: Class, state: State }) {
5858
.map(([flag, title]) => (
5959
<TypeSpan key={flag} flag={flag} title={title} />
6060
));
61-
61+
6262
const currentYear = parseInt(state.term.fullRealYear);
63-
const nextAcademicYearStart = state.term.semester === "f" ? currentYear + 1 : currentYear;
63+
const nextAcademicYearStart =
64+
state.term.semester === "f" ? currentYear + 1 : currentYear;
6465
const nextAcademicYearEnd = nextAcademicYearStart + 1;
6566

6667
const types1 = makeFlags([
@@ -100,11 +101,10 @@ function ClassTypes(props: { cls: Class, state: State }) {
100101
) : (
101102
""
102103
);
103-
104-
const unitsDescription =
105-
cls.isVariableUnits
106-
? "Units arranged"
107-
: `${totalUnits} units: ${units.join("-")}`;
104+
105+
const unitsDescription = cls.isVariableUnits
106+
? "Units arranged"
107+
: `${totalUnits} units: ${units.join("-")}`;
108108

109109
return (
110110
<Flex gap={4} align="center">
@@ -116,9 +116,7 @@ function ClassTypes(props: { cls: Class, state: State }) {
116116
<Flex gap={1}>{types2}</Flex>
117117
{halfType}
118118
</Flex>
119-
<Text>
120-
{unitsDescription}
121-
</Text>
119+
<Text>{unitsDescription}</Text>
122120
{flags.final ? <Text>Has final</Text> : null}
123121
</Flex>
124122
);
@@ -133,9 +131,7 @@ function ClassRelated(props: { cls: Class; state: State }) {
133131
<>
134132
<Text>Prereq: {linkClasses(state, prereq)}</Text>
135133
{same !== "" && <Text>Same class as: {linkClasses(state, same)}</Text>}
136-
{meets !== "" && (
137-
<Text> Meets with: {linkClasses(state, meets)} </Text>
138-
)}
134+
{meets !== "" && <Text> Meets with: {linkClasses(state, meets)} </Text>}
139135
</>
140136
);
141137
}
@@ -199,10 +195,7 @@ function ClassDescription(props: { cls: Class; state: State }) {
199195
}
200196

201197
/** Full non-class activity description, from title to timeslots. */
202-
function NonClassDescription(props: {
203-
activity: NonClass;
204-
state: State;
205-
}) {
198+
function NonClassDescription(props: { activity: NonClass; state: State }) {
206199
const { activity, state } = props;
207200

208201
return (
@@ -211,10 +204,7 @@ function NonClassDescription(props: {
211204
<Flex direction="column" gap={2}>
212205
{activity.timeslots?.map((t) => (
213206
<Flex key={t.toString()} align="center" gap={2}>
214-
<Button
215-
size="sm"
216-
onClick={() => state.removeTimeslot(activity, t)}
217-
>
207+
<Button size="sm" onClick={() => state.removeTimeslot(activity, t)}>
218208
Remove
219209
</Button>
220210
<Text>{t.toString()}</Text>

src/components/App.tsx

+21-15
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function useHydrant(): {
6969
classesMap,
7070
new Term(termInfo),
7171
lastUpdated,
72-
new Term(latestTerm)
72+
new Term(latestTerm),
7373
);
7474
hydrantRef.current = hydrantObj;
7575
setLoading(false);
@@ -132,9 +132,13 @@ function HydrantApp() {
132132
window.alert(`${callback} is not allowed to read your class list!`);
133133
return;
134134
}
135-
const encodedClasses = (hydrant.selectedActivities.filter((activity) => activity instanceof Class) as Class[])
135+
const encodedClasses = (
136+
hydrant.selectedActivities.filter(
137+
(activity) => activity instanceof Class,
138+
) as Class[]
139+
)
136140
.map((cls) => `&class=${cls.number}`)
137-
.join('');
141+
.join("");
138142
const filledCallback = `${callback}?hydrant=true${encodedClasses}`;
139143
window.location.replace(filledCallback);
140144
}, [hydrant, hasIntegrationCallback, hash]);
@@ -144,21 +148,19 @@ function HydrantApp() {
144148
const onICSExport = useICSExport(
145149
hydrant!,
146150
() => setIsExporting(false),
147-
() => setIsExporting(false)
151+
() => setIsExporting(false),
148152
);
149153

150154
return (
151155
<>
152-
{(!hydrant || hasIntegrationCallback) ? (
156+
{!hydrant || hasIntegrationCallback ? (
153157
<Flex w="100%" h="100vh" align="center" justify="center">
154158
<Spinner />
155159
</Flex>
156160
) : (
157161
<Flex w="100%" direction={{ base: "column", lg: "row" }} p={4} gap={8}>
158162
<Flex direction="column" w={{ base: "100%", lg: "50%" }} gap={6}>
159-
<Header
160-
preferences={state.preferences}
161-
state={hydrant} />
163+
<Header preferences={state.preferences} state={hydrant} />
162164
<ScheduleOption
163165
selectedOption={state.selectedOption}
164166
totalOptions={state.totalOptions}
@@ -169,9 +171,7 @@ function HydrantApp() {
169171
viewedActivity={state.viewedActivity}
170172
state={hydrant}
171173
/>
172-
<LeftFooter
173-
state={hydrant}
174-
/>
174+
<LeftFooter state={hydrant} />
175175
</Flex>
176176
<Flex direction="column" w={{ base: "100%", lg: "50%" }} gap={6}>
177177
<ScheduleSwitcher
@@ -200,13 +200,19 @@ function HydrantApp() {
200200
? "Loading..."
201201
: "At the moment, only manually exporting to an .ics file is supported. " +
202202
"We are still working on fixing Google Calendar export!"
203-
}>
204-
<Button colorScheme="blue" size="sm" leftIcon={<CalendarIcon/>} onClick={onICSExport}>
203+
}
204+
>
205+
<Button
206+
colorScheme="blue"
207+
size="sm"
208+
leftIcon={<CalendarIcon />}
209+
onClick={onICSExport}
210+
>
205211
{isExporting ? <Spinner m={3} /> : "Import to my calendar"}
206212
</Button>
207213
</Tooltip>
208-
<MatrixLink selectedActivities={state.selectedActivities}/>
209-
<SIPBLogo/>
214+
<MatrixLink selectedActivities={state.selectedActivities} />
215+
<SIPBLogo />
210216
</HStack>
211217
</Center>
212218
<SelectedActivities

src/components/Calendar.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export function Calendar(props: {
6868
return hour === 12
6969
? "noon"
7070
: hour < 12
71-
? `${hour} AM`
72-
: `${hour - 12} PM`;
71+
? `${hour} AM`
72+
: `${hour - 12} PM`;
7373
}}
7474
slotMinTime="08:00:00"
7575
slotMaxTime="22:00:00"
@@ -81,8 +81,8 @@ export function Calendar(props: {
8181
viewedActivity,
8282
Timeslot.fromStartEnd(
8383
Slot.fromStartDate(e.start),
84-
Slot.fromStartDate(e.end)
85-
)
84+
Slot.fromStartDate(e.end),
85+
),
8686
);
8787
}}
8888
/>

0 commit comments

Comments
 (0)