Skip to content

Commit 288e753

Browse files
committed
fix: deprecate typing.List in favor of list (#10)
1 parent dbf0e78 commit 288e753

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,31 +83,31 @@ class Status:
8383
@dataclass
8484
class RootObject:
8585
page = Page
86-
components = List[Components]
87-
incidents = List[Any]
88-
scheduled_maintenances = List[Any]
86+
components = list[Components]
87+
incidents = list[Any]
88+
scheduled_maintenances = list[Any]
8989
status = Status
9090
```
9191

9292
Or:
9393

9494
```python
95-
from typing import TypedDict, Optional, List
95+
from typing import TypedDict, Optional
9696

9797
from datetime import datetime
9898

9999

100100
IncidentUpdate = TypedDict("IncidentUpdate", {"body": str, "created_at": datetime, "display_at": datetime, "id": str, "incident_id": str, "status": str, "updated_at": datetime})
101101

102-
IncidentOrScheduledMaintenance = TypedDict("IncidentOrScheduledMaintenance", {"created_at": datetime, "id": str, "impact": str, "incident_updates": List[IncidentUpdate], "monitoring_at": None, "name": str, "page_id": str, "resolved_at": None, "shortlink": str, "status": str, "updated_at": datetime, "scheduled_for": Optional[datetime], "scheduled_until": Optional[datetime]})
102+
IncidentOrScheduledMaintenance = TypedDict("IncidentOrScheduledMaintenance", {"created_at": datetime, "id": str, "impact": str, "incident_updates": list[IncidentUpdate], "monitoring_at": None, "name": str, "page_id": str, "resolved_at": None, "shortlink": str, "status": str, "updated_at": datetime, "scheduled_for": Optional[datetime], "scheduled_until": Optional[datetime]})
103103

104104
Component = TypedDict("Component", {"created_at": datetime, "description": None, "id": str, "name": str, "page_id": str, "position": int, "status": str, "updated_at": datetime})
105105

106106
Status = TypedDict("Status", {"description": str, "indicator": str})
107107

108108
Page = TypedDict("Page", {"id": str, "name": str, "url": str, "updated_at": datetime})
109109

110-
RootObject = TypedDict("UnnammedType3C2BC8", {"page": Page, "status": Status, "components": List[Component], "incidents": List[IncidentOrScheduledMaintenance], "scheduled_maintenances": List[IncidentOrScheduledMaintenance]})
110+
RootObject = TypedDict("UnnammedType3C2BC8", {"page": Page, "status": Status, "components": list[Component], "incidents": list[IncidentOrScheduledMaintenance], "scheduled_maintenances": list[IncidentOrScheduledMaintenance]})
111111
```
112112

113113
## TODO

src/target/python_class.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn write_output(
147147
}
148148
}
149149
Type::Array(inner) => {
150-
imports_from_typing.insert("List");
150+
imports_from_typing.insert("list");
151151
if schema.arena.get(inner).unwrap().is_any() {
152152
imports_from_typing.insert("Any");
153153
}
@@ -272,7 +272,7 @@ impl<'i, 'c> Display for Contexted<&'i Type, Context<'c>> {
272272
}
273273
Type::Array(r#type) => {
274274
// dbg!(r#type);
275-
write!(f, "List[{}]", self.wrap(schema.arena.get(*r#type).unwrap()))
275+
write!(f, "list[{}]", self.wrap(schema.arena.get(*r#type).unwrap()))
276276
}
277277
Type::Int => write!(f, "int"),
278278
Type::Float => write!(f, "float"),

src/target/python_inline.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ fn write_output(
140140
}
141141
}
142142
Type::Array(inner) => {
143-
imports_from_typing.insert("List");
144143
if schema.arena.get(inner).unwrap().is_any() {
145144
imports_from_typing.insert("Any");
146145
}
@@ -261,7 +260,7 @@ impl<'c> Display for Contexted<ArenaIndex, Context<'c>> {
261260
Ok(())
262261
}
263262
Type::Array(inner) => {
264-
write!(f, "List[{}]", self.wrap(inner))
263+
write!(f, "list[{}]", self.wrap(inner))
265264
}
266265
Type::Int => write!(f, "int"),
267266
Type::Float => write!(f, "float"),

0 commit comments

Comments
 (0)