Skip to content
This repository has been archived by the owner on May 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #31 from herczy/master
Browse files Browse the repository at this point in the history
Upgrade tools and supported versions
  • Loading branch information
attilammagyar authored Feb 28, 2018
2 parents ff8b940 + b0b5b54 commit 9e9a458
Show file tree
Hide file tree
Showing 24 changed files with 282 additions and 244 deletions.
337 changes: 216 additions & 121 deletions .pylintrc

Large diffs are not rendered by default.

21 changes: 12 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
language: python
python: 3.4
sudo: false

env:
- TOX_ENV=py32
- TOX_ENV=py33
- TOX_ENV=py34
matrix:
include:
- python: 3.4
env:
- TOX_ENV=py34
- python: 3.5
env:
- TOX_ENV=py35
- python: 3.6
env:
- TOX_ENV=py36

install:
- case ${TOX_ENV} in
py32) pip install virtualenv\<14 --upgrade;;
*) pip install virtualenv --upgrade;;
esac
- pip install virtualenv --upgrade
- pip install tox

script:
Expand Down
2 changes: 1 addition & 1 deletion features/environment.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
2 changes: 1 addition & 1 deletion features/steps/steps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
6 changes: 3 additions & 3 deletions scripts/copyright.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/python3
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down Expand Up @@ -49,10 +49,10 @@ def match_patterns(text, patterns):
with open(os.path.join(BASE_PATH, 'copyright.txt')) as f:
COPYRIGHT_TEXT = f.read()
FILTER_EXTENSION = {'.py', '.sh'}
BEGIN_PATTERN = re.compile(r"^Copyright \(c\) 2013-(20[0-9]{2}) BalaBit$")
BEGIN_PATTERN = re.compile(r"^Copyright \(c\) 2013-(20[0-9]{2}) Balabit$")

UPDATE_COPYRIGHT_HEADER = '''
Copyright (c) 2013-{year} BalaBit
Copyright (c) 2013-{year} Balabit
{copyright}\
'''.format(year=THIS_YEAR, copyright=COPYRIGHT_TEXT)

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down Expand Up @@ -38,7 +38,7 @@
are valid.
""",
license="LGPLv2+",
version="1.0.3",
version="2.0.0",
author="Viktor Hercinger",
author_email="[email protected]",
maintainer="Viktor Hercinger",
Expand Down
18 changes: 6 additions & 12 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,26 +1,20 @@
[tox]
envlist=py34,py33,py32
envlist=py36,py35,py34

[testenv]
deps=
nose
pytest
mock
pep8
pycodestyle

py34,py33: pylint
py32: logilab-common==0.62.1
py32: astroid==1.2.1
py32: pylint==1.3.1
pylint
behave

py33,py34: behave
py32: behave==1.2.4
py33,py32: enum34
coverage

py34,py33: coverage
py32: coverage<4.0.0
commands=
pep8 --repeat typesafety
pycodestyle --max-line-length 120 --repeat typesafety
pylint -f parseable --rcfile=.pylintrc typesafety
nosetests --with-coverage --with-doctest typesafety
behave
Expand Down
2 changes: 1 addition & 1 deletion typesafety/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
4 changes: 2 additions & 2 deletions typesafety/autodecorator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down Expand Up @@ -135,7 +135,7 @@ def __set_attribute(self, module, key, value):
# We want to catch all errors here since any problems with setting
# a module attribute to the decorated function is non-fatal.
# pylint: disable=W0702
except:
except: # noqa
if hasattr(module, '__module__'):
name = '{}.{}'.format(module.__module__, module.__name__)

Expand Down
7 changes: 5 additions & 2 deletions typesafety/finder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down Expand Up @@ -141,8 +141,11 @@ def find_module(self, fullname, path=None):
This will do nothing, since we use the system to locate a module.
'''

loader = None
if self.__filter is None or self.__filter(fullname):
return ModuleLoader(self, fullname, path)
loader = ModuleLoader(self, fullname, path)

return loader

def load_module(self, loader):
'''
Expand Down
4 changes: 2 additions & 2 deletions typesafety/noseplugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down Expand Up @@ -80,7 +80,7 @@ def options(self, parser, env):
'(useful when debugging typesafety)'
)

def configure(self, options, config):
def configure(self, options, conf):
if options.enable_typesafety:
self.enabled = True
self.__enabled_for = tuple(
Expand Down
2 changes: 1 addition & 1 deletion typesafety/pytest_typesafety.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
2 changes: 1 addition & 1 deletion typesafety/pytests/check_pytest_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
2 changes: 1 addition & 1 deletion typesafety/sphinxautodoc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
2 changes: 1 addition & 1 deletion typesafety/tests/externalmodule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
19 changes: 1 addition & 18 deletions typesafety/tests/mockmodule.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand All @@ -19,33 +19,16 @@
import collections

from . import mockmodule2
from .version import is_above_version

# External objects not native to this module
from .externalmodule import UndecoratedClass, undecorated_function


if not is_above_version('3.2'):
class ClassWithSlots:
__slots__ = ['mutable']

@property
def immutable(self):
return 1

@property
def mutable(self):
return 2


def function():
pass


class ModuleClass(object):
def __init__(self):
super(ModuleClass, self).__init__()

def method(self):
pass

Expand Down
2 changes: 1 addition & 1 deletion typesafety/tests/mockmodule2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
15 changes: 1 addition & 14 deletions typesafety/tests/test_autodecorator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand All @@ -18,8 +18,6 @@
import sys
import unittest

from .version import skip_above_version

from ..autodecorator import decorate_module


Expand Down Expand Up @@ -67,17 +65,6 @@ def __unload_test_module(self, name):
if fullname in sys.modules:
del sys.modules[fullname]

@skip_above_version(
"3.2",
"Defining slots this way causes a ValueError, so they become " +
"unreachable for the autodecorator. Every other fix like this " +
"in other software simply removes slot entries " +
"like ClassWithSlots.mutable."
)
def test_immutable_class_attributes_are_not_decorated(self):
self.assertEqual(1, self._module.ClassWithSlots().immutable)
self.assertEqual(1234, self._module.ClassWithSlots().mutable)

def test_dont_decorate_objects_not_native_to_the_module(self):
self.assertEqual(2, self._module.UndecoratedClass().method(1))
self.assertEqual(3, self._module.undecorated_function(1))
2 changes: 1 addition & 1 deletion typesafety/tests/test_finder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
2 changes: 1 addition & 1 deletion typesafety/tests/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand Down
44 changes: 8 additions & 36 deletions typesafety/tests/test_sphinxautodoc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2016 BalaBit
# Copyright (c) 2013-2018 Balabit
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
Expand All @@ -19,12 +19,12 @@
import collections

from functools import wraps
from .version import skip_above_version, skip_below_or_at_version

from typesafety.sphinxautodoc import add_annotations_to_signature
from ..sphinxautodoc import add_annotations_to_signature


class TestAnnotatedDocsForMethodSignatures(unittest.TestCase):
# Is a test suite, can have as many public methods as needed.
class TestAnnotatedDocsForMethodSignatures(unittest.TestCase): # pylint: disable=too-many-public-methods
def test_only_functions_classes_and_and_methods_are_considered(self):
self.__assert_signature_docs_override(
None,
Expand Down Expand Up @@ -196,20 +196,6 @@ def test_decorated_methods_are_resolved_when_decor_func_attr_is_set(self):
ExampleClass.method_with_decorators
)

@skip_above_version(
"3.3",
"For some reason, version(s) 3.3+ handle annotations of decorated "
"functions differently. In 3.4 this seems to be fixed."
)
def test_decorated_methods_should_not_trigger_inifinite_loop(self):
self.__assert_signature_docs_override(
("(*args, **kwargs)", ""),
"method",
"ExampleClass.method_with_recursive_decorator",
ExampleClass.method_with_recursive_decorator
)

@skip_below_or_at_version("3.3", "See the exact explanation above")
def test_decorated_methods_dont_trigger_inf_loop_but_return_none(self):
self.__assert_signature_docs_override(
None,
Expand All @@ -218,20 +204,6 @@ def test_decorated_methods_dont_trigger_inf_loop_but_return_none(self):
ExampleClass.method_with_recursive_decorator
)

@skip_above_version(
"3.3",
"For some reason, version(s) 3.3+ handle annotations of decorated " +
"functions differently. In 3.4 this seems to be fixed."
)
def test_decorated_methods_should_not_trigger_errors(self):
self.__assert_signature_docs_override(
("(*args, **kwargs)", ""),
"method",
"ExampleClass.method_with_messed_up_decorator",
ExampleClass.method_with_messed_up_decorator
)

@skip_below_or_at_version("3.3", "See the exact explanation above")
def test_decorated_methods_should_not_trigger_errors_but_return_none(self):
self.__assert_signature_docs_override(
None,
Expand Down Expand Up @@ -286,7 +258,7 @@ def function_with_annotated_varargs(an_int, *varargs: list, **varkwargs: dict):
pass


def function_with_complex_default_value(a_tuple: tuple=(1, 2, 3)):
def function_with_complex_default_value(a_tuple: tuple = (1, 2, 3)):
pass


Expand Down Expand Up @@ -329,8 +301,8 @@ def __init__(self, an_int: int):
def method_with_default_value(
self,
a_float: float,
an_int: int=42,
an_str: str=""
an_int: int = 42,
an_str: str = ""
):
pass

Expand All @@ -340,7 +312,7 @@ def method_with_varargs(self, an_int: int, *varargs, **varkwargs):
def method_with_kwonly_arg(self, a_float: float, *, an_int: int):
pass

def method_with_default_value_for_self(self=None, an_int: int=42):
def method_with_default_value_for_self(self=None, an_int: int = 42):
pass

def method_with_class_names(self, an_object: SomeClass) -> SomeClass:
Expand Down
Loading

0 comments on commit 9e9a458

Please sign in to comment.