-
Notifications
You must be signed in to change notification settings - Fork 93
Reduced the type: ignore comments and allocated the structured dataclass #393
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
Reduced the type: ignore comments and allocated the structured dataclass #393
Conversation
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.
In principle, I like it. IMO -- besides the usual bits and pieces that need to be fixed -- for whatever reason it seems that a lot of unrelated formatting changes slipped into this (which makes reviewing it more difficult than it needs to be and also prevents the CI from passing). To fix the formatting, install yapf
and isort
via pip and run the reformat-source.sh script in the toplevel directory of your working copy...
Overall executed the
|
…rmat-source.sh etc.
yes. ideally you run this script before you commit anything, so you don't need to worry about the formatting... |
(before you push to github, it is IMO advisable to run |
Ok let me work on it and thanks for letting me know |
…o refractor_compare_tool
…o refractor_compare_tool
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.
1. refractored the code by adding dataclass and formated using reformat.sh
2. Verfied using ruff and mypy
odxtools/cli/compare.py
Outdated
class ServiceSpecs: | ||
diag_layer: str | ||
diag_layer_type: str | ||
new_services: List[DiagService] # List of new service name |
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.
comments that just repeat variable name are redundant
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.
are you sure that you have run the reformatting script? On my machine it still conducts quite a few changes on this PR:
~/src/odxtools|7f75ca4... > ./reformat-source.sh
Fixing /home/and/src/odxtools/odxtools/request.py
Fixing /home/and/src/odxtools/odxtools/response.py
Fixing /home/and/src/odxtools/odxtools/odxtypes.py
Fixing /home/and/src/odxtools/odxtools/version.py
Fixing /home/and/src/odxtools/odxtools/nameditemlist.py
Fixing /home/and/src/odxtools/odxtools/basicstructure.py
Fixing /home/and/src/odxtools/odxtools/cli/compare.py
Fixing /home/and/src/odxtools/odxtools/diaglayers/hierarchyelement.py
Fixing /home/and/src/odxtools/tests/test_compu_methods.py
~/src/odxtools|7f75ca4... > git diff --stat
odxtools/cli/compare.py | 398 +++++++++++++++++-------------------------------
1 file changed, 136 insertions(+), 262 deletions(-)
odxtools/cli/compare.py
Outdated
|
||
if service_spec["deleted_services"]: | ||
if service_specs.deleted_services: | ||
assert isinstance(service_specs.deleted_services, List) |
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.
that assert should be superfluous now...
odxtools/cli/compare.py
Outdated
if service_spec["changed_name_of_service"][0]: | ||
rich_print(extract_service_tabulation_data(service_specs.deleted_services)) | ||
if service_specs.changed_name_of_service: | ||
# assert isinstance(service_specs.changed_name_of_service[0], List) |
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.
only leave such "ruins" in the code base in exceptional circumstances (IMO this is not one of these)
odxtools/cli/compare.py
Outdated
for variant in changes_variants["deleted_diagnostic_layers"]: | ||
assert isinstance(variant, DiagLayer) | ||
rich_print( | ||
f" [magenta]{variant.short_name}[/magenta] ({variant.variant_type.value})") | ||
|
||
# diagnostic services | ||
for _, value in changes_variants.items(): | ||
if isinstance(value, dict): | ||
self.print_dl_changes(value) |
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.
where did this go?
odxtools/cli/compare.py
Outdated
# add old service name (type: String) | ||
service_dict["changed_name_of_service"][1].append(service2.short_name) | ||
# service_specs.changed_name_of_service[1].append(service2.short_name) |
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.
this seems to have gone MIA?
|
c82509d
to
23f1323
Compare
since we raised the minimum python version to 3.10, ruff now complains. the good news is that running |
@andlaus I used the same command |
Thanks |
Hi @andlaus Can you please help me with resolving this lint issue. I executed the same ruff command in local repo but after resolving the conflicts it is failing I guess.
Thanks |
weird: it seems like that for whatever reason, ruff starts complaining about the auto-generated file |
thanks for the fix. it still does not work, but I suspect that this is due to leftover artifacts from packaging (the offending file is in the |
for whatever reason, ruff starts to care about the `build/` subdirectory with mercedes-benz#393 . Since this is probably an artifact of pip, let's just delete this directory before linting. Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com> Signed-off-by: Christian Hackenbeck <christian.hackenbeck@mercedes-benz.com>
I opened a PR for this PR: vinothk-master#1 . I hope that after you've merged it, the issue is fixed. Note that, due to my unfamiliarity with github actions, I was unable to test if it works... |
for whatever reason, ruff starts to care about the `build/` subdirectory with mercedes-benz#393 . Since this is probably an artifact of pip, let's just delete this directory before linting. Signed-off-by: Andreas Lauser <andreas.lauser@mercedes-benz.com> Signed-off-by: Christian Hackenbeck <christian.hackenbeck@mercedes-benz.com>
attempt to fix the github actions
Thanks @andlaus ! I have merged your workflow fix. |
…o refractor_compare_tool
…aster/odxtools into refractor_compare_tool
seems like my fix worked. merging, thanks for your patience! |
Hi @andlaus
Added these set of lines which is used to reduce the
type :ignore
comments incompare.py
file which increases the readability and to maintain a structured dict. Please check these line commits and let me know I can help on this regard.class SpecsServiceDict(TypedDict): diag_layer: str diag_layer_type: str new_services: List[str] # List of new service names deleted_services: List[DiagService] # List of deleted services renamed_service: List[Tuple[str, DiagService]] # List of (old_name, DiagService) changed_name_of_service: List[Tuple[str, DiagService]] # Similar to renamed_service changed_parameters_of_service: List[Tuple[str, DiagService, List[Union[str, int, float]]]] class SpecsChangesVariants(TypedDict): new_variants : List[str] deleted_variants : List[str] service_changes : SpecsServiceDict
Thanks
Vinoth Kannan