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

Lrpc 9 use pylint #17

Merged
merged 73 commits into from
Oct 12, 2024
Merged

Lrpc 9 use pylint #17

merged 73 commits into from
Oct 12, 2024

Conversation

tzijnge
Copy link
Owner

@tzijnge tzijnge commented Sep 18, 2024

No description provided.

tzijnge and others added 30 commits May 13, 2024 20:56
* Added accessors for service, struct and enum to LrpcDef
* Trigger actions on all branches
* Added accessor for field_idto LrpcEnum
* Added accessor for returns and params to LrpcFun
* Some type hints in LrpcFun
* Added accessor for function to LrpcService
* Some type hints in LrpcService
* Added packing information to LrpcVar
* Some type hints in LrpcVar
* Some refactoring
* Client as module
* Added encoder
* Added client
* moved test files to generic location
* Added initial version of client/decoder.py
* Added LrpcDef.load
* decode optional
* refactoring for string decode
* Some refactoring to allow trailing bytes
* Additional implementation of lrpc_encode and lrpc_decode
* Update lrpc_visitor.py with type hints and documentation
* Small update on LrpcVisitor and applied it on derived classes
* schema is now a package
* Moved tests
* LrpcDef can now load properly as an installed package
* Added LrpcDef.service_by_id()
* renamed LrpcDef.service to LrpcDef.service_by_name()
* Use absolute file locations
* Improved LrpcClient
* Added LrpcService.function_by_id() and renamed LrpcService.function_by_id() to LrpcService.function_by_name()
* Added LrpcVar.base_type_is_bool() and LrpcVar.base_type_is_float()
* Some new tests
* Completed lrpc.client module
* Initial version of LRPC client CLI
* Added schema to Python package as package data
* Run LRPC command line tools
* Implementation of lrpcc, some modifications to ClientCliVisitor
* Update readme
* Add pyserial to dependencies
* Added run_lrpcc_config_creator to show help and create a config template in case no config was found
* Added typehints
* Cleanup
* Revert wrong changes from previous commit
* Added pyproject.toml with black config
* Applied black to function.py
* Update setup.py
# Conflicts (resolved):
#	package/lrpc/PlantUmlVisitor.py
#	package/lrpc/__init__.py
#	package/lrpc/client/client_cli_visitor.py
#	package/lrpc/client/decoder.py
#	package/lrpc/client/encoder.py
#	package/lrpc/client/lrpc_client.py
#	package/lrpc/codegen/constants.py
#	package/lrpc/codegen/struct.py
#	package/lrpc/core/definition.py
#	package/lrpc/core/function.py
#	package/lrpc/core/service.py
#	package/lrpc/core/struct.py
#	package/lrpc/core/var.py
#	package/lrpc/lrpc_visitor.py
#	package/lrpc/lrpcc.py
#	package/lrpc/validation/enum.py
#	package/lrpc/validation/names.py
#	package/lrpc/validation/service.py
#	package/setup.py
#	package/tests/test_lrpc_decode.py
* Added github action for mypy with reviewdog
@@ -1,85 +1,88 @@
from code_generation.code_generator import CppFile
import os
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "code_generation.code_generator" [import-not-found]

with self.file.block(f'class {self.service_name}ServiceShim : public lrpc::Service', ';'):
self.file.label('public')
self.file(f'uint32_t id() const override {{ return {self.service_id}; }}')
def __write_shim(self) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Type of decorated function contains type "Any" ("Callable[..., Any]") [misc]

from lrpc.core import LrpcDef, LrpcService
import os

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "code_generation.code_generator" [import-not-found]

self.file.newline()
self.__write_server_class(self.lrpc_def.namespace())

@optionally_in_namespace
def __write_server_class(self):
def __write_server_class(self) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Type of decorated function contains type "Any" ("Callable[..., Any]") [misc]

from code_generation.code_generator import CppFile
import os
from typing import Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "code_generation.code_generator" [import-not-found]


@optionally_in_namespace
def __write_constant_definitions(self):
def __write_constant_definitions(self) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Type of decorated function contains type "Any" ("Callable[..., Any]") [misc]

from typing import Set

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "code_generation.code_generator" [import-not-found]


@optionally_in_namespace
def __write_external_alias(self):
def __write_external_alias(self) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Type of decorated function contains type "Any" ("Callable[..., Any]") [misc]


@optionally_in_namespace
def __write_struct(self):
with self.file.block(f'struct {self.__qualified_name()}', ';'):
def __write_struct(self) -> None:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Type of decorated function contains type "Any" ("Callable[..., Any]") [misc]

from lrpc.core import LrpcFun, LrpcService, LrpcVar
import os

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "code_generation.code_generator" [import-not-found]

from code_generation.code_generator import CppFile
import os
from typing import Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

from lrpc.core import LrpcFun, LrpcService, LrpcVar
import os

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

from code_generation.code_generator import CppFile
import os
from typing import Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

@@ -1,85 +1,88 @@
from code_generation.code_generator import CppFile
import os
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

from typing import Set

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

from lrpc.core import LrpcDef, LrpcService
import os

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

@@ -1,75 +1,77 @@
import struct
from typing import Optional, Any

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused Optional imported from typing (unused-import)

@@ -1,9 +1,10 @@
import pytest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
C0103: Module name "test_LrpcDef" doesn't conform to snake_case naming style (invalid-name)

* Avoid circular imports by using relative imports inside package
* Fix some PyLint warnings
* Moved visitors to separate module
* moved code to load LrpcDef to separate module utils.load_definition.py
self.write(")")


class PlantUmlVisitor(LrpcVisitor):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
R0902: Too many instance attributes (14/7) (too-many-instance-attributes)

self.puml.list_item(f"ID: {service.id()}", level=0)
self.puml.list_end()

self.max_function_id = max([f.id() for f in service.functions()])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
R1728: Consider using a generator instead 'max(f.id() for f in service.functions())' (consider-using-generator)

tzijnge added 7 commits September 26, 2024 20:03
* Fix mistake in file name
* Enable build with MSVC
* Enable build with MSVC
* C++ version to 14 for now
* Compiler warnings as errors off for now
* Some refactoring to get rid of compiler warnings
* Fix compiler warnings
* Some formatting
* Install Python requirements for MSVC
@github-advanced-security
Copy link

This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation.

tzijnge added 3 commits September 27, 2024 19:28
* Fix wrong file name
* MSVC code analysis configuration
* Fix remaining MyPy issues
@@ -1,11 +1,10 @@
from typing import Callable, Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Cannot find implementation or library stub for module named "code_generation.code_generator" [import-not-found]

@@ -1,11 +1,10 @@
from typing import Callable, Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
E0401: Unable to import 'code_generation.code_generator' (import-error)

* Fix some SonarCloud issues
from typing import List
from lrpc.core import LrpcDef
from lrpc.validation import ServiceChecker, FunctionChecker, EnumChecker, NamesChecker, CustomTypesChecker
from typing import Any

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[pylint] reported by reviewdog 🐶
W0611: Unused Any imported from typing (unused-import)

* Added type param for PathLike
* enabled mypy check for any generics
self.output = output
self.function_info = None
self.function_info: dict
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "dict" [type-arg]

def visit_lrpc_service(self, service: LrpcService):
self.file = CppFile(f'{self.output}/{service.name()}_ServiceShim.hpp')
self.function_info = dict()
self.function_declarations: list
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "list" [type-arg]

self.file = CppFile(f'{self.output}/{service.name()}_ServiceShim.hpp')
self.function_info = dict()
self.function_declarations: list
self.function_shims: list
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "list" [type-arg]

self.function_info = dict()
self.function_declarations: list
self.function_shims: list
self.function_params: list
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "list" [type-arg]

self.function_declarations: list
self.function_shims: list
self.function_params: list
self.function_returns: list
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "list" [type-arg]

Call ClientCliVisitor.root() to activate the CLI
"""

def __init__(self, callback: Callable) -> None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "Callable" [type-arg]

def __handle_command(self, service, function, **kwargs):
return t

def __handle_command(self, service: Optional[str], function: str, **kwargs: Any) -> Callable:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "Callable" [type-arg]



def __load_config():
def __load_config() -> Optional[dict]:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "dict" [type-arg]

yaml.safe_dump(lrpcc_config, lrpcc_config_file)

print(f"Created file {LRPCC_CONFIG_YAML}")


class Lrpcc:
def __init__(self, config) -> None:
self.lrpc_def: LrpcDef = LrpcDef.load(config[DEFINITION_URL])
def __init__(self, config: dict) -> None:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "dict" [type-arg]


if self.transport_type == "serial":
self.__communicate: callable = self.__communicate_serial
self.__communicate: Callable = self.__communicate_serial
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Missing type parameters for generic type "Callable" [type-arg]

tzijnge added 4 commits October 1, 2024 19:18
* Fix more mypy issues
* Some renaming and refactoring to reduce SonarCloud and Pylint issues
* Added double underscore prefix to 'private' variables
* Disabled some Pylint issues
* LrpcVar.pack_type raises error for optional, array, string and struct
* Fixing more MyPy and PyLint issues
* Added logging to report definition warnings and errors
* Normalized loading LrpcDef from various sources
@@ -1,11 +1,11 @@
from typing import Optional
from collections.abc import Callable
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

from lrpc.codegen.utils import optionally_in_namespace
import os
from typing import Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

import os
from typing import Optional

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

from lrpc.codegen.utils import optionally_in_namespace
import os
from typing import Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

from typing import Set, List
import os
from typing import Optional
from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

import os
from typing import Optional, Set

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

from lrpc.codegen.common import lrpc_var_includes
import os

from code_generation.code_generator import CppFile # type: ignore[import-untyped]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [mypy] reported by reviewdog 🐶
Unused "type: ignore" comment [unused-ignore]

* Fixing more MyPy and PyLint issues
* Improved error handling and logging
Copy link

sonarcloud bot commented Oct 10, 2024

@tzijnge tzijnge merged commit 3510950 into main Oct 12, 2024
9 checks passed
@tzijnge tzijnge deleted the LRPC-9-use-pylint branch October 12, 2024 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant