Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaopeuko committed Apr 27, 2024
1 parent 98cf30f commit d1dbea6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
43 changes: 21 additions & 22 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,34 @@ name: Python package

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest poetry
poetry export -f requirements.txt --output requirements.txt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest poetry
poetry export -f requirements.txt --output requirements.txt
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
- [Example 2: Custom Usage](#example-2-custom-usage)
- [Features](#features)


Secure your Python data structures and secrets with Secured. This package provides a straightforward solution for obscuring sensitive data in applications. It's specifically designed for developers who need to protect API keys, database credentials, and other critical configuration details from accidental exposure. Featuring customizable security measures, our tool allows you to control how sensitive information is represented and managed securely. It's ideal for projects that demand high data confidentiality and integrity. Please note that this provides a thin layer of protection.

## Installation
Expand Down Expand Up @@ -52,4 +51,4 @@ print(secure_api_key) # Output: API Key Protected

- **Data Protection**: Helps prevent the accidental logging or display of sensitive information.
- **Customizable Representations**: Set how your data is displayed when being secured.
- **Ease of Use**: Integrate seamlessly into existing Python applications.
- **Ease of Use**: Integrate seamlessly into existing Python applications.
2 changes: 1 addition & 1 deletion secured/log_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def setup_default_logger():
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)
return logger
return logger
6 changes: 3 additions & 3 deletions secured/secured.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from .attribute import AttrDict

class Secured:
def __init__(self, yaml_paths: str | List[str] = None, secure: bool = False,
def __init__(self, yaml_paths: str | List[str] = None, secure: bool = False,
as_attrdict: bool = True, message: str = "<Sensitive data secured>", logger=None):
"""
Initialize a Secured object to manage YAML configuration securely.
Args:
yaml_paths: Paths to YAML files that should be loaded.
secure: Flag to determine if data should be secured. Defaults to False.
Expand Down Expand Up @@ -98,7 +98,7 @@ def get(self, key: str, required: bool = False) -> Secure | None:
"""
env_value = os.getenv(key)
if env_value is not None:
return Secure(env_value, self.message)
return Secure(env_value, self.message)
if required:
self.logger.error(f"Key '{key}' not found in configuration or OS environment.")
raise ValueError(f"Key '{key}' not found.")
Expand Down

0 comments on commit d1dbea6

Please sign in to comment.