Skip to content

Add flake 8 linting configuration #6

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 119
max-complexity = 10
per-file-ignores = __init__.py:F401
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ publish to test.pypi.org to make sure that whl is built correctly and can be ins
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
```

publish to pypi
publish to pypi
```sh
python -m twine upload dist/*
```
2 changes: 1 addition & 1 deletion hsl_builder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .base import BaseElement


__all__= [
__all__ = [
'Button',
'CarouselWidth',
'Carousel',
Expand Down
5 changes: 3 additions & 2 deletions hsl_builder/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .base import BaseElement
from .elements.actionable import Actionable


class Button(BaseElement):
"""
Create Button HSL Elements
Expand All @@ -12,8 +13,8 @@ class Button(BaseElement):
list of actionables that will be added to the button

"""
def __init__(self,text):
super().__init__(text,'BUTTON')
def __init__(self, text):
super().__init__(text, 'BUTTON')
self.actionables: List[Actionable] = []

def to_hsl(self):
Expand Down
7 changes: 4 additions & 3 deletions hsl_builder/carousel.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from enum import Enum,unique
from enum import Enum, unique
from typing import List

from .base import BaseElement
from .elements.carousel_item import CarouselItem


@unique
class CarouselWidth(Enum):
THIN = 'THIN'
Expand All @@ -27,8 +28,8 @@ class Carousel(BaseElement):
items : List[CarouselItem]
list of carousel items for the carousel
"""
def __init__(self,text):
super().__init__(text,'CAROUSEL')
def __init__(self, text):
super().__init__(text, 'CAROUSEL')
self.aspect_ratio: float = 1.0
self.width: CarouselWidth = CarouselWidth.THIN
self.items: List[CarouselItem] = []
Expand Down
2 changes: 1 addition & 1 deletion hsl_builder/elements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .carousel_item import CarouselItem
from .silent_action import SilentAction

__all__=[
__all__ = [
'FormField',
'Actionable',
'SilentAction',
Expand Down
18 changes: 10 additions & 8 deletions hsl_builder/elements/actionable.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from enum import unique,Enum
from enum import unique, Enum


@unique
class URI(Enum):
Expand All @@ -19,7 +20,7 @@ class URI(Enum):
@unique
class ActionableType(Enum):
"""
Actionable Types for specifying what action should be taken
Actionable Types for specifying what action should be taken
"""
APP_ACTION = 'APP_ACTION'
MESSAGE_BAR = 'MESSAGE_BAR'
Expand All @@ -28,29 +29,30 @@ class ActionableType(Enum):
SHARE_RECEIPT = 'SHARE_RECEIPT'
APP_FEEDBACK = 'APP_FEEDBACK'
SHARE = 'SHARE'



class Actionable(object):
"""
Create Actionables to be used in Buttons or Text messages

Attributes
----------
text : str
Text for the Actionable that will be displayed on the CTA (button, quick reply,etc).
Text for the Actionable that will be displayed on the CTA (button, quick reply, etc).

type : ActionableType
The type of `ActionableType`.

type : URI
The type of `URI`.

location_required : bool
True if location is required for using the Actionable.

is_default : bool
if True, on click of the element, this actionable will get triggered.

payload : dict
payload : dict
optional payload containing metadata that might be needed by the Actionable
"""

Expand Down
8 changes: 4 additions & 4 deletions hsl_builder/elements/carousel_item.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from .actionable import Actionable
from typing import List


class CarouselItem(object):
"""
Create Carousel Items for Carousel
Expand All @@ -9,10 +10,10 @@ class CarouselItem(object):
----------
title : str
Title of specific carousel item.

subtitle : str
Subtitle of specific carousel item.

description : str
More verbose description of item that is shown below the subtitle

Expand All @@ -23,8 +24,7 @@ class CarouselItem(object):
meta value for the corresponding carousal item
"""


def __init__(self,title: str, subtitle: str):
def __init__(self, title: str, subtitle: str):
self.title: str = title
self.subtitle: str = subtitle
self.description: str = ''
Expand Down
10 changes: 6 additions & 4 deletions hsl_builder/elements/form_field.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from enum import Enum,unique
from enum import Enum, unique
from typing import List


@unique
class FormFieldType(Enum):
TEXT = 'text'
Expand All @@ -17,6 +18,7 @@ class FormFieldType(Enum):
MULTI_DAY_PICKER = 'multidaypicker'
MULTI_SELECT_PICKER = 'multiselectpicker'


@unique
class FormKeyboardType(Enum):
NORMAL = 'normal'
Expand All @@ -43,7 +45,7 @@ class FormField(object):
order : int
The order of the form

icon : str
icon : str
Icon name for the field.

hint : str
Expand All @@ -59,7 +61,7 @@ class FormField(object):
search_placeholder : str
placeholder when no text is entered for search type fields

autofill : str
autofill : str
Auto fill field based on user profile or default value.

auto_fill_source : str
Expand Down Expand Up @@ -94,5 +96,5 @@ def to_hsl(self) -> dict:
'search_placeholder': self.search_placeholder,
'autofill': self.autofill,
'autofill_source': self.autofill_source,
#TODO: add regex fields
# TODO: add regex fields
}
8 changes: 4 additions & 4 deletions hsl_builder/elements/silent_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class SilentAction(object):
----------
type : str
Type of silent action.

via_name : str
via_name of the corresponding business.


action_id : str
id of the silent action.

data : dict
options that will be sent as payload
"""
Expand Down
2 changes: 1 addition & 1 deletion hsl_builder/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Form(object):
list of formfields that will be added to the form

"""
def __init__(self,text: str, subtitle: str):
def __init__(self, text: str, subtitle: str):
self.title: str = text
self.type: str = 'FORM'
self.subtitle: str = subtitle
Expand Down
7 changes: 4 additions & 3 deletions hsl_builder/native_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ class NativeAction(BaseElement):
Attributes
----------
method : str
the method name for the native action
the method name for the native action
"""
def __init__(self,text: str, method: str):
super().__init__(text,'NATIVE_ACTION')

def __init__(self, text: str, method: str):
super().__init__(text, 'NATIVE_ACTION')
self.method = method

def to_hsl(self):
Expand Down
5 changes: 3 additions & 2 deletions hsl_builder/silent.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .elements import SilentAction


class Silent(BaseElement):
"""
Create Silent Message HSL
Expand All @@ -12,8 +13,8 @@ class Silent(BaseElement):
actions : List[SilentAction]
list of silent acitons to be taken
"""
def __init__(self,text: str):
super().__init__(text,'SILENT')
def __init__(self, text: str):
super().__init__(text, 'SILENT')
self.actions: List[SilentAction] = []

def to_hsl(self):
Expand Down
8 changes: 5 additions & 3 deletions hsl_builder/system.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from .base import BaseElement
from enum import unique,Enum
from enum import unique, Enum


@unique
class SystemEvents(Enum):
PINNED = 'chat_pinned'
COMPLETE = 'chat_complete'


class System(BaseElement):
"""
create system messages hsl
Expand All @@ -18,8 +20,8 @@ class System(BaseElement):
payload : dict
additonal data sent as payload
"""
def __init__(self,text :str,event_name: SystemEvents):
super().__init__(text,'SYSTEM')
def __init__(self, text: str, event_name: SystemEvents):
super().__init__(text, 'SYSTEM')
self.event = event_name
self.payload = {}

Expand Down
7 changes: 5 additions & 2 deletions hsl_builder/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@
from .base import BaseElement
from .elements.actionable import Actionable


class Text(BaseElement):
"""
Create simple text message HSL
"""
def __init__(self,text):
super().__init__(text,'TEXT')

def __init__(self, text):
super().__init__(text, 'TEXT')
self.quick_replies: List[Actionable] = []

def to_hsl(self):
"""
Generate HSL message
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from setuptools import setup,find_packages
from setuptools import setup, find_packages


with open("README.md", "r") as fh:
Expand All @@ -11,6 +11,6 @@
license='MIT',
long_description=long_description,
long_description_content_type="text/markdown",
packages=find_packages(exclude=('tests',)),
packages=find_packages(exclude=('tests', )),
zip_safe=False,
url="https://github.com/hellohaptik/python-hsl")
24 changes: 12 additions & 12 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from .test_actionable import *
from .test_base import *
from .test_button import *
from .test_carousel import *
from .test_carousel_item import *
from .test_form import *
from .test_form_field import *
from .test_native_action import *
from .test_silent import *
from .test_silent_action import *
from .test_system import *
from .test_text import *
from .test_actionable import ActionableTest
from .test_base import BaseTest
from .test_button import ButtonTest
from .test_carousel import CarouselTest
from .test_carousel_item import CarouselItemTest
from .test_form import FormTest
from .test_form_field import FormFieldTest
from .test_native_action import NativeActionTest
from .test_silent import SilentTest
from .test_silent_action import SilentItemTest
from .test_system import SystemCompleteTest, SystemWaitingTest
from .test_text import TextTest
4 changes: 3 additions & 1 deletion tests/mocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from hsl_builder.elements import Actionable, FormField, CarouselItem, SilentAction


class MockActionable(Actionable):

def __init__(self):
Expand All @@ -11,13 +12,14 @@ class MockFormField(FormField):
def __init__(self):
pass


class MockCarouselItem(CarouselItem):

def __init__(self):
pass


class MockSilentAction(SilentAction):

def __init__(self):
pass

4 changes: 2 additions & 2 deletions tests/test_actionable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mock
from unittest import TestCase, main
from hsl_builder.elements import Actionable, URI, ActionableType


class ActionableTest(TestCase):

def setUp(self):
Expand All @@ -21,7 +21,7 @@ def test_default_hsl(self):
"""
verify the default hsl generated
"""
self.assertDictEqual(self.actionable.to_hsl(),self.expected_hsl)
self.assertDictEqual(self.actionable.to_hsl(), self.expected_hsl)

def test_actionable_type_APP_ACTION(self):
"""
Expand Down
Loading