Skip to content

Commit

Permalink
Fix codacy issues
Browse files Browse the repository at this point in the history
* add codacy config file
* fix security relevant issues
  • Loading branch information
cmeissner committed Jun 4, 2021
1 parent 6138737 commit 2711745
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
8 changes: 8 additions & 0 deletions .codacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
exclude_paths:
- '.github/**'
- '.vscode/**'
- 'CHANGELOG.md'
- 'CONTRIBUTING.md'
- 'docs/**'
- 'README.md'
2 changes: 1 addition & 1 deletion click_types/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""Python package that provides custom click types"""
"""Python package that provides custom click types."""
14 changes: 7 additions & 7 deletions click_types/ansible.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module for custom click types regarding to ansible"""
"""Module for custom click types regarding to ansible."""

import click
import os
Expand Down Expand Up @@ -64,7 +64,7 @@ def convert(self, value, param, ctx):
data = self.v.load(open(self.vault).read())
except AnsibleError as e:
if 'not vault encrypted data' in str(e):
data = yaml.load(open(self.vault).read(), SafeLoader) or {}
data = yaml.safe_load(open(self.vault).read(), SafeLoader) or {}
except Exception as e:
self.fail('Decryption failed: {0}'.format(str(e)), param, ctx)

Expand All @@ -74,26 +74,26 @@ def convert(self, value, param, ctx):

try:
self.v.dump(data, open(self.vault, 'w'))
except: # noqa: E722
except Exception:
self.fail('Error while encrypting data', param, ctx)

return self.path

def _populate_data(self, input={}, keys=[], value=None):
def _populate_data(self, origin: dict = None, keys: list = None, value: str = None):
"""Save value at the desired position in vault.
This method takes vault data, a list of keys where to store the value.
:param input: The dictionary of vault data, defaults to {}
:type input: dict, optional
:param origin: The dictionary of vault data, defaults to {}
:type origin: dict, optional
:param keys: List of keys that describe the desired position in vault, defaults to []
:type keys: list, optional
:param value: The value to store in vault, defaults to None
:type value: str, optional
:return: The vault data extended by `value` at the desired position.
:rtype: dict
"""
data = input.copy()
data = origin.copy()

if keys:
key = keys[0]
Expand Down
2 changes: 1 addition & 1 deletion click_types/coding.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module for custom click types regarding to development"""
"""Module for custom click types regarding to development."""

import semver

Expand Down
2 changes: 1 addition & 1 deletion click_types/net.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Module for custom click types regarding to network"""
"""Module for custom click types regarding to network."""

import click
import ipaddress
Expand Down

0 comments on commit 2711745

Please sign in to comment.