(self, data_type: PythonType | GithubClass | None)
| 1272 | self.ids = ids |
| 1273 | |
| 1274 | def get_value(self, data_type: PythonType | GithubClass | None) -> Any: |
| 1275 | if data_type is None: |
| 1276 | return cst.Name("None") |
| 1277 | if isinstance(data_type, GithubClass): |
| 1278 | return cst.Name(data_type.name.split(".")[-1]) |
| 1279 | # data_type is PythonType |
| 1280 | if data_type.type == "bool": |
| 1281 | return cst.Name("False") |
| 1282 | if data_type.type == "int": |
| 1283 | return cst.Integer("0") |
| 1284 | if data_type.type == "float": |
| 1285 | return cst.Float("0.0") |
| 1286 | if data_type.type == "str": |
| 1287 | return cst.SimpleString('""') |
| 1288 | if data_type.type == "datetime": |
| 1289 | return cst.Call( |
| 1290 | func=cst.Name("datetime"), |
| 1291 | args=[ |
| 1292 | cst.Arg(cst.Integer("2020")), |
| 1293 | cst.Arg(cst.Integer("1")), |
| 1294 | cst.Arg(cst.Integer("2")), |
| 1295 | cst.Arg(cst.Integer("12")), |
| 1296 | cst.Arg(cst.Integer("34")), |
| 1297 | cst.Arg(cst.Integer("56")), |
| 1298 | cst.Arg( |
| 1299 | keyword=cst.Name("tzinfo"), |
| 1300 | equal=equal, |
| 1301 | value=self.create_attribute(["timezone", "utc"]), |
| 1302 | ), |
| 1303 | ], |
| 1304 | ) |
| 1305 | return cst.SimpleString(f'"{data_type}"') |
| 1306 | |
| 1307 | def leave_Module(self, original_node: Module, updated_node: Module) -> Module: |
| 1308 | # add from __future__ import annotations if not the first import |
no test coverage detected