Skip to content

Commit

Permalink
Typing changes (#10)
Browse files Browse the repository at this point in the history
* updating version.

* adding mypy and pytest to requirements-test.txt

* adding py.typed.

* running blue

* adding docstrings to __init__.py

* fixing pylint errors

* adding pylint and mypy badges

* adding lint checks.
  • Loading branch information
tybruno authored Jun 20, 2024
1 parent aae0b27 commit 5fa92f4
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 18 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/lint-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: linting

on: workflow_call

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6']
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install blue
pip install pylint
pip install pylama
pip install mypy
- name: Check blue
run: |
blue . --check
- name: Analysing the code with pylama
run: |
pylama --skip='tests/*'
- name: Analysing the code with pylint
run: |
pylint caseless_dictionary/
- name: Analysing the code with mypy
run: |
mypy caseless_dictionary/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
[![Code Style: Blue](https://img.shields.io/badge/code%20style-blue-0000ff.svg)](https://github.com/psf/blue)
[![License: MIT](https://img.shields.io/badge/License-MIT-blueviolet.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/gh/tybruno/caseless-dictionary/branch/main/graph/badge.svg?token=ZO94EJFI3G)](https://codecov.io/gh/tybruno/caseless-dictionary)
[![Pylint](https://img.shields.io/badge/Pylint-10.0%2F10-green)](10.0/10)
[![Mypy](https://img.shields.io/badge/Mypy-checked-blue)](10.0/10)

# caseless-dictionary

Expand Down
24 changes: 24 additions & 0 deletions caseless_dictionary/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
"""
Caseless dictionary is a dictionary that is case-insensitive and allows access
to keys in different cases.
The caseless dictionary module provides the following classes:
- CaselessDict: A case-insensitive dictionary that allows access to keys in
different cases.
- UpperCaselessDict: A case-insensitive dictionary that converts keys to
uppercase.
- TitleCaselessDict: A case-insensitive dictionary that converts keys to
title case.
- SnakeCaselessDict: A case-insensitive dictionary that converts keys to
snake case.
- KebabCaselessDict: A case-insensitive dictionary that converts keys to
kebab case.
- ConstantCaselessDict: A case-insensitive dictionary that converts keys to
constant case.
- CaselessAttrDict: A case-insensitive dictionary that allows access to
keys in different cases using attribute access.
- SnakeCaselessAttrDict: A case-insensitive dictionary that allows access
to keys in different cases using snake case attribute access.
- ConstantCaselessAttrDict: A case-insensitive dictionary that allows
access to keys in different cases using constant case attribute access.
"""
from caseless_dictionary.caseless_attribute_dict import (
CaselessAttrDict,
SnakeCaselessAttrDict,
Expand Down
1 change: 1 addition & 0 deletions caseless_dictionary/caseless_attribute_dict.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=duplicate-code
"""
This module contains classes that implement case-insensitive attribute
dictionaries.
Expand Down
Empty file added caseless_dictionary/py.typed
Empty file.
4 changes: 3 additions & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Test Requirements
pytest
pytest-cov
blue
blue
pylint
mypy
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
setup,
)

__version__ = 'v2.0.0'
__version__ = 'v2.0.1'
__author__ = 'Tyler Bruno'
DESCRIPTION = (
'Typed and Tested Case Insensitive Dictionary which was '
Expand Down
23 changes: 13 additions & 10 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

import pytest

from caseless_dictionary import SnakeCaselessAttrDict, \
ConstantCaselessAttrDict, CaselessAttrDict, KebabCaselessDict, \
CaselessDict, ConstantCaselessDict, UpperCaselessDict, SnakeCaselessDict, \
TitleCaselessDict
from caseless_dictionary import (
SnakeCaselessAttrDict,
ConstantCaselessAttrDict,
CaselessAttrDict,
KebabCaselessDict,
CaselessDict,
ConstantCaselessDict,
UpperCaselessDict,
SnakeCaselessDict,
TitleCaselessDict,
)


class _TestingClass(NamedTuple):
Expand Down Expand Up @@ -85,9 +92,7 @@ def valid_mapping(request) -> Mapping:
_TestingClass(TitleCaselessDict, _title),
_TestingClass(SnakeCaselessDict, _snake_case),
_TestingClass(KebabCaselessDict, _kebab_case),
_TestingClass(
ConstantCaselessDict, _constant_case
),
_TestingClass(ConstantCaselessDict, _constant_case),
)
)
def caseless_class(request) -> _TestingClass:
Expand All @@ -98,9 +103,7 @@ def caseless_class(request) -> _TestingClass:
@pytest.fixture(
params=(
_TestingClass(SnakeCaselessAttrDict, _snake_case),
_TestingClass(
ConstantCaselessAttrDict, _constant_case
),
_TestingClass(ConstantCaselessAttrDict, _constant_case),
)
)
def caseless_attr_class(request) -> _TestingClass:
Expand Down
4 changes: 1 addition & 3 deletions tests/test_caseless_attribute_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ class TestCaselessAttributeDictionary:
"""

def test__init__mapping(
self, valid_mapping: Mapping, caseless_attr_class
):
def test__init__mapping(self, valid_mapping: Mapping, caseless_attr_class):
_class, _key_operation = caseless_attr_class
caseless_attr_dict = _class(valid_mapping)
expected = {
Expand Down
4 changes: 1 addition & 3 deletions tests/test_caseless_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@


class TestCaselessDictionary:
def test__init__mapping(
self, valid_mapping: Mapping, caseless_class
):
def test__init__mapping(self, valid_mapping: Mapping, caseless_class):
_class, _key_operation = caseless_class
caseless_dict = _class(valid_mapping)
expected = {
Expand Down

0 comments on commit 5fa92f4

Please sign in to comment.