Skip to content

Commit

Permalink
Merge pull request #575 from Hugovdberg/fix_black_errors
Browse files Browse the repository at this point in the history
Fix issues with testing / security updates
  • Loading branch information
Hugovdberg authored Jul 26, 2021
2 parents fed90e1 + 83fbe81 commit f613360
Show file tree
Hide file tree
Showing 6 changed files with 597 additions and 515 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [$default-branch]
pull_request:
branches: [$default-branch]

jobs:
build:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: [2.7, 3.6, 3.7, 3.8]

steps:
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pipenv
python -m pipenv sync -d
- name: Check formatting with black
run: |
# stop the build if there are Python syntax errors or undefined names
black --check --diff PIconnect
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
63 changes: 21 additions & 42 deletions PIconnect/AFSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,55 +72,45 @@

# pragma pylint: disable=invalid-name, unused-argument, too-few-public-methods
class AF:
"""Mock class of the AF namespace
"""
"""Mock class of the AF namespace"""

class Data:
"""Mock class of the AF.Data namespace
"""
"""Mock class of the AF.Data namespace"""

class AFBoundaryType(enum.IntEnum):
"""Mock class of the AF.Data.AFBoundaryType enumeration
"""
"""Mock class of the AF.Data.AFBoundaryType enumeration"""

Inside = 0
Outside = 1
Interpolated = 2

class PI:
"""Mock class of the AF.PI namespace
"""
"""Mock class of the AF.PI namespace"""

class PIPoint:
"""Mock class of the AF.PI.PIPoint class
"""
"""Mock class of the AF.PI.PIPoint class"""

@staticmethod
def FindPIPoints(connection, query, source, attribute_names):
"""Stub to mock querying PIPoints
"""
"""Stub to mock querying PIPoints"""
return []

class PIServer:
"""Mock class of the AF.PI.PIServer class
"""
"""Mock class of the AF.PI.PIServer class"""

def __init__(self, name):
self.Name = name

def Connect(self, retry):
"""Stub for connecting to test server
"""
"""Stub for connecting to test server"""
pass

def Disconnect(self):
"""Stub for disconnecting from test server
"""
"""Stub for disconnecting from test server"""
pass

class PIServers:
"""Mock class of the AF.PI.PIServers class
"""
"""Mock class of the AF.PI.PIServers class"""

DefaultPIServer = None

Expand All @@ -136,27 +126,23 @@ def __iter__(self):
return (x for x in [self.DefaultPIServer])

class AFElement:
"""Mock class of the AF.AFElement class
"""
"""Mock class of the AF.AFElement class"""

def __init__(self, name):
self.Name = name

class AFDatabase:
"""Mock class of the AF.AFDatabase class
"""
"""Mock class of the AF.AFDatabase class"""

def __init__(self, name):
self.Name = name
self.Elements = [AF.AFElement("TestElement")]

class PISystem:
"""Mock class of the AF.PISystem class
"""
"""Mock class of the AF.PISystem class"""

class InternalDatabases:
"""Mock class for the AF.PISystem.Databases property
"""
"""Mock class for the AF.PISystem.Databases property"""

def __init__(self):
self.DefaultDatabase = AF.AFDatabase("TestDatabase")
Expand All @@ -169,19 +155,16 @@ def __init__(self, name):
self.Databases = AF.PISystem.InternalDatabases()

def Connect(self):
"""Stub to connect to the testing system
"""
"""Stub to connect to the testing system"""
pass

def Disconnect(self):
"""Stub to disconnect from the testing system
"""
"""Stub to disconnect from the testing system"""

pass

class PISystems:
"""Mock class of the AF.PISystems class
"""
"""Mock class of the AF.PISystems class"""

DefaultPISystem = None
Version = "0.0.0.0"
Expand All @@ -198,27 +181,23 @@ def __iter__(self):
return (x for x in [self.DefaultPISystem])

class Time:
"""Mock class of the AF.Time namespace
"""
"""Mock class of the AF.Time namespace"""

class AFTimeRange:
"""Mock class of the AF.Time.AFTimeRange class
"""
"""Mock class of the AF.Time.AFTimeRange class"""

def __init__(self, start_time, end_time):
pass

class AFTimeSpan:
"""Mock class of the AF.Time.AFTimeSpan class
"""
"""Mock class of the AF.Time.AFTimeSpan class"""

def __init__(self):
pass

@staticmethod
def Parse(interval):
"""Stub for parsing strings that should return a AFTimeSpan
"""
"""Stub for parsing strings that should return a AFTimeSpan"""
return AF.Time.AFTimeSpan()

# pragma pylint: enable=invalid-name, unused-argument, too-few-public-methods
10 changes: 5 additions & 5 deletions PIconnect/_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
def operate(operator, operand):
"""Create a decorator to apply an operator to the function and a given operand.
Operand can be either a constant or a function which accepts the same arguments
as the base function to which the decorator is applied. Operator must be a
function of two arguments.
Operand can be either a constant or a function which accepts the same arguments
as the base function to which the decorator is applied. Operator must be a
function of two arguments.
"""

@wrapt.decorator
Expand Down Expand Up @@ -92,8 +92,8 @@ def build_operator_method(method, operator, docstring, cls):
def patch_members(self, other):
"""Return new object of class *newclassname* with patched members.
Creates a new virtual class with the members in *members* patched to apply
the given *operator* to the original function definition.
Creates a new virtual class with the members in *members* patched to apply
the given *operator* to the original function definition.
"""
newmembers = {
member: decorate(
Expand Down
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,19 @@ piconnect = {editable = true,path = "."}
[dev-packages]
black = "*"
tox = "*"
coverage = "*"
mypy = "*"
# coverage = "*"
# mypy = "*"
pylint = "*"
pytest = "*"
pytest-runner = "*"
Sphinx = "*"
PyYAML = "*"
"doc8" = "*"
"flake8" = "*"
twine = "*"

[requires]
python_version = "3.7"
python_version = "3.8"

[pipenv]
allow_prereleases = true
Loading

0 comments on commit f613360

Please sign in to comment.