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

Feature.extendprecommit #375

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

Conversation

Josephine-Rutten
Copy link
Collaborator

Ectended the pre-commit and solved the issues that mypy marked

src/cnaas_nms/plugins/ni.py Fixed Show fixed Hide fixed
src/cnaas_nms/plugins/ni.py Fixed Show fixed Hide fixed
src/cnaas_nms/plugins/ni.py Dismissed Show dismissed Hide dismissed
src/cnaas_nms/plugins/ni.py Dismissed Show dismissed Hide dismissed
.pre-commit-config.yaml Show resolved Hide resolved
require_serial: true
verbose: true
args:
- --no-warn-incomplete-stub
Copy link
Member

Choose a reason for hiding this comment

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

Were these required for cnaas-nms or like a basic config copied from somewhere?

Copy link
Collaborator Author

@Josephine-Rutten Josephine-Rutten Nov 26, 2024

Choose a reason for hiding this comment

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

The args have been checked and are needed for cnaas-nms. Might be good to keep an eye on that. It could be a good idea to check if the issues we ignore now could be good code improvements, but for now I thought this code improvement was getting really big and it was better to improve it incremental. The other settings I took from Workflow Orchestrator.

src/cnaas_nms/api/auth.py Outdated Show resolved Hide resolved
src/cnaas_nms/api/device.py Outdated Show resolved Hide resolved
@@ -566,7 +568,7 @@ def post(self, device_id: int):

if mlag_peer_id:
try:
mlag_peer_dev: Device = cnaas_nms.devicehandler.init_device.pre_init_checks(session, mlag_peer_id)
mlag_peer_dev = cnaas_nms.devicehandler.init_device.pre_init_checks(session, mlag_peer_id)
Copy link
Member

Choose a reason for hiding this comment

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

why not a device?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We already defined the name with type. We don't want to redefine the variable. We are also not allowed to redefine it the same type.

src/cnaas_nms/devicehandler/sync_devices.py Outdated Show resolved Hide resolved
@@ -31,14 +31,14 @@ def update_interfacedb_worker(
replace: bool,
delete_all: bool,
mlag_peer_hostname: Optional[str] = None,
linknets: Optional[List[dict]] = None,
linknets: List[dict] = [],
Copy link
Member

Choose a reason for hiding this comment

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

same here with list as default argument

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We could make it None, but it does mean you need a lot of extra checking on the type. I thought the empty list had the same result, without having 2 types for one variable. If you prefer the None, I could add the checks and work like that.

with sqla_session() as session:
dev: Device = session.query(Device).filter(Device.hostname == hostname).one()
with sqla_session() as session: # type: ignore
dev = session.query(Device).filter(Device.hostname == hostname).one()
Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Collaborator Author

@Josephine-Rutten Josephine-Rutten Nov 26, 2024

Choose a reason for hiding this comment

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

We defined the variable type earlier in the same function. The best solution would maybe be to split the function up in smaller functions as we now do a lot in one function. But for now it works if we don't redefine the type.

src/cnaas_nms/tools/dhcp_hook.py Outdated Show resolved Hide resolved
src/cnaas_nms/tools/jinja_filters.py Outdated Show resolved Hide resolved
Copy link

sonarcloud bot commented Nov 28, 2024

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.

2 participants