-
Notifications
You must be signed in to change notification settings - Fork 236
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 mypy to CI pipeline and begin typing modules #435
Merged
Pierre-Sassoulas
merged 9 commits into
pytest-dev:master
from
gnikonorov:issue_434_begin_integration
Nov 20, 2024
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
927096a
Add mypy to CI pipeline and begin typing effort
gnikonorov 9d91f18
Merge branch 'master' into issue_434_begin_integration
Pierre-Sassoulas 2bea39c
Merge remote-tracking branch 'origin/master' into issue_434_begin_int…
Pierre-Sassoulas 64900e7
move from setup.cfg to pyproject.toml
Pierre-Sassoulas 6f567e7
Add noqa in testing/test_integration.py
Pierre-Sassoulas e04622f
Make some hard options false to begin with something
Pierre-Sassoulas 49e404e
Revert "Add noqa in testing/test_integration.py"
Pierre-Sassoulas f1426c4
Fix merge conflict badly fixed
Pierre-Sassoulas 9f23c75
Remove some type:ignore
Pierre-Sassoulas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,13 @@ repos: | |
- [email protected] | ||
- [email protected] | ||
args: ["--fix"] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.13.0 | ||
hooks: | ||
- id: mypy | ||
files: ^(src/pytest_html|testing) | ||
additional_dependencies: | ||
- types-setuptools | ||
- repo: local | ||
hooks: | ||
- id: rst | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
from typing import Dict | ||
from typing import Optional | ||
|
||
FORMAT_HTML = "html" | ||
FORMAT_IMAGE = "image" | ||
|
@@ -10,7 +12,13 @@ | |
FORMAT_VIDEO = "video" | ||
|
||
|
||
def extra(content, format_type, name=None, mime_type=None, extension=None): | ||
def extra( | ||
content: str, | ||
format_type: str, | ||
name: Optional[str] = None, | ||
mime_type: Optional[str] = None, | ||
extension: Optional[str] = None, | ||
) -> Dict[str, Optional[str]]: | ||
return { | ||
"name": name, | ||
"format_type": format_type, | ||
|
@@ -20,41 +28,51 @@ def extra(content, format_type, name=None, mime_type=None, extension=None): | |
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
to make this more clear, i suggest to define a variable with the return type of |
||
|
||
def html(content): | ||
def html(content: str) -> Dict[str, Optional[str]]: | ||
return extra(content, FORMAT_HTML) | ||
|
||
|
||
def image(content, name="Image", mime_type="image/png", extension="png"): | ||
def image( | ||
content: str, | ||
name: str = "Image", | ||
mime_type: str = "image/png", | ||
extension: str = "png", | ||
) -> Dict[str, Optional[str]]: | ||
return extra(content, FORMAT_IMAGE, name, mime_type, extension) | ||
|
||
|
||
def png(content, name="Image"): | ||
def png(content: str, name: str = "Image") -> Dict[str, Optional[str]]: | ||
return image(content, name, mime_type="image/png", extension="png") | ||
|
||
|
||
def jpg(content, name="Image"): | ||
def jpg(content: str, name: str = "Image") -> Dict[str, Optional[str]]: | ||
return image(content, name, mime_type="image/jpeg", extension="jpg") | ||
|
||
|
||
def svg(content, name="Image"): | ||
def svg(content: str, name: str = "Image") -> Dict[str, Optional[str]]: | ||
return image(content, name, mime_type="image/svg+xml", extension="svg") | ||
|
||
|
||
def json(content, name="JSON"): | ||
def json(content: str, name: str = "JSON") -> Dict[str, Optional[str]]: | ||
return extra(content, FORMAT_JSON, name, "application/json", "json") | ||
|
||
|
||
def text(content, name="Text"): | ||
def text(content: str, name: str = "Text") -> Dict[str, Optional[str]]: | ||
return extra(content, FORMAT_TEXT, name, "text/plain", "txt") | ||
|
||
|
||
def url(content, name="URL"): | ||
def url(content: str, name: str = "URL") -> Dict[str, Optional[str]]: | ||
return extra(content, FORMAT_URL, name) | ||
|
||
|
||
def video(content, name="Video", mime_type="video/mp4", extension="mp4"): | ||
def video( | ||
content: str, | ||
name: str = "Video", | ||
mime_type: str = "video/mp4", | ||
extension: str = "mp4", | ||
) -> Dict[str, Optional[str]]: | ||
return extra(content, FORMAT_VIDEO, name, mime_type, extension) | ||
|
||
|
||
def mp4(content, name="Video"): | ||
def mp4(content: str, name: str = "Video") -> Dict[str, Optional[str]]: | ||
return video(content, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since
__version
is an optioanl import at the time typecheckers run,i usggest to typehint
__version__
alathis makes type checkers aware that
__version__
is supposed to be a sting and warn/fail if it is not