Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing return type hint for resources.py #1906

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vetleledaal
Copy link

What?

jira/resources.py::Issue::permalink is an untyped function, it should be typed.

Why?

The jira module advertises itself as supporting type hints via py.typed. When used in a typed context and with mypy's strict mode it will complain about the current implementation.

How?

Adding return type hints to jira/resources.py would mitigate the issue.

Testing?

$ cat test.py
from jira.resources import Issue

x = Issue()  # type: ignore
x.permalink()
# Before:
$ mypy --strict test.py | grep '^test\.py'
test.py:4: error: Call to untyped function "permalink" in typed context  [no-untyped-call]
$ _

# After:
$ mypy --strict test.py | grep '^test\.py'
$ _

Has not been tested in runtime. With PEP 563 it is impossible for this PR to break anything under normal conditions. Worst case is that tools used during development show incorrect information, such as an LSP or linter.

Anything Else?

While adding type hints everywhere would be ideal, the PR scope is limited for easier reviewability.

Changes can be summarized as; all methods return None, except for:

  • jira/resources.py::Attachment::get, which returns bytes | None
  • jira/resources.py::Issue::permalink, which returns str

Closes #1900.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable strict type-checking
1 participant