Mentions légales du service
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
declearn2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Magnet
DecLearn
declearn2
Commits
912d579a
Verified
Commit
912d579a
authored
2 months ago
by
ANDREY Paul
Browse files
Options
Downloads
Patches
Plain Diff
Silence mypy warnings to be fixed when dropping py38 support.
parent
4a4027aa
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#1100322
failed
2 months ago
Stage: clean
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
declearn/utils/_dataclass.py
+3
-1
3 additions, 1 deletion
declearn/utils/_dataclass.py
declearn/utils/_toml_config.py
+4
-2
4 additions, 2 deletions
declearn/utils/_toml_config.py
with
7 additions
and
3 deletions
declearn/utils/_dataclass.py
+
3
−
1
View file @
912d579a
...
...
@@ -204,5 +204,7 @@ def _parameters_to_fields(
ftype
=
Dict
[
str
,
ftype
]
# type: ignore
field
.
default_factory
=
dict
# Append parsed information to the fields list.
fields
.
append
((
fname
,
ftype
,
field
))
fields
.
append
(
(
fname
,
ftype
,
field
)
# type: ignore # update when py >=3.9
)
return
fields
This diff is collapsed.
Click to expand it.
declearn/utils/_toml_config.py
+
4
−
2
View file @
912d579a
...
...
@@ -139,7 +139,7 @@ def _instantiate_field(
origin
=
typing
.
get_origin
(
field
.
type
)
# Case of a raw type.
if
origin
is
None
:
return
_instantiate
(
field
.
type
)
return
_instantiate
(
field
.
type
)
# type: ignore # update when py >=3.9
# Case of a union of types (including optional).
if
origin
is
Union
:
for
cls
in
typing
.
get_args
(
field
.
type
):
...
...
@@ -284,7 +284,9 @@ class TomlConfig:
Instantiated object that matches the field
'
s specifications.
"""
# Case of valid inputs: return them as-is (including valid None).
if
_isinstance_generic
(
inputs
,
field
.
type
):
# see function's notes
if
_isinstance_generic
(
inputs
,
field
.
type
# type: ignore # update when py >=3.9
):
# see function's notes
return
inputs
# Case of None inputs: return default value if any, else raise.
if
inputs
is
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment