Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Issues with DateTime ISO fields

未关闭
#29 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
python
领域
api

调研方向

首先检查 gql/renderer_dataclasses.py 第 153–160 行附近的代码,尤其是 nullable DateTime 字段如何处理 suffix,以及何时选择 DATETIME_FIELD。使用 DateTime 结果重现 gql_run 查询,并验证生成的 dataclass 能够在不出现所报告的 TypeError 的情况下反序列化返回的 ISO 值。

由索引模型根据 Issue 内容生成。

描述

when i run gql_run and the renderer_dataclasses.py encounters a DateTime field it generates a field:

var_name: datetime = None

when I run a query that returns a datetime object I get the following error:

File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 220, in _decode_generic
    res = _get_type_cons(type_)(xs)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 260, in <genexpr>
    for x in xs)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 165, in _decode_dataclass
    infer_missing)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 179, in _decode_dataclass
    dt = datetime.fromtimestamp(field_value, tz=tz)
TypeError: an integer is required (got type str)

I think this is because in:
https://github.com/graphql-python/gql-next/blob/5c81e58862c8df3a335b81bb2f77a0fab2c50570/gql/renderer_dataclasses.py#L153-L160

suffix is being overwritten if the field is nullable and DATETIME_FIELD isn't being used.

主要语言
Python
星标
78
派生
6
PR 合并指标
30 天内没有已合并 PR

环境准备

我们还没有检查这个项目的环境配置文件。先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphql-python/gql-next 的其他 Issue

查看 graphql-python/gql-next 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。