Support Type Hints

未关闭
#2,794 4 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
25/100
Issue 类型
功能
描述清晰度
需要澄清
活跃度
停滞
技术栈
python

调研方向

首先检查剩余的、尚未勾选的任务,以启用 Ruff 的 ANN 规则,并将其与 #2808 和 #2812 中已经完成的 Mypy 工作进行比较。完成意味着项目的类型提示政策已经确定,相关检查已启用,并且所需的注解通过了这些检查。

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

描述

longterm typing

This issue is still in draft mode. Type hints are something new to me, so I need to learn more and will keep improving the issue description.

What's Python's Type Hints
Why we should support type hints

Copied from https://vegibit.com/introduction-to-python-type-hints/.

  • Improved code readability: Type hints make it easier for other developers to understand your code. By clearly specifying the types of arguments and return values, you can help others quickly grasp the intent of your code.
  • Improved development speed: With type hints, you can catch potential bugs and errors early in the development process. This can save you time in the long run, as you can fix errors before they cause problems in your code.
  • Improved tooling support: Many tools, such as static analyzers and IDEs, use type hints to provide better support for your code. For example, they can use type hints to catch potential errors, suggest code improvements, or provide better autocompletion.
  • Better auto-completion for parameter values: See #2793 for how Type Hints can affect the way we use PyGMT.
Tasks
  • Use Mypy for static type checking #2808
  • #2812
  • Enable ruff's ANN rules to make sure all parameters are annotated? [Maybe it's unnecessary, because mypy has a strict mode]
References:
Related PEPs
主要语言
Python
星标
882
派生
261
平均合并
1 天 3 小时
30 天内合并 PR
29

环境准备

从这里开始

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

GenericMappingTools/pygmt 的其他 Issue

查看 GenericMappingTools/pygmt 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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