Skip to content

Commit 9d14b2e

Browse files
committed
Unify part of code with logwrap
* coverage rules * MANIFEST.in * use _version.py * part of setup.py * coverage on azure
1 parent 86d1597 commit 9d14b2e

File tree

16 files changed

+140
-57
lines changed

16 files changed

+140
-57
lines changed

.azure_pipelines/run_tests.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ jobs:
4040
4141
- script: |
4242
pip install -U wheel
43-
python setup.py bdist_wheel
44-
pip install --pre --no-index -f dist advanced-descriptors
43+
python setup.py develop -v
4544
displayName: Build and install
4645
4746
- script: |
48-
pip install pytest pytest-sugar
47+
pip install pytest pytest-sugar pytest-cov
4948
50-
pytest -vvv --junitxml=unit_result.xml test
49+
pytest -vvv --junitxml=unit_result.xml --cov=advanced_descriptors --cov-report=xml --cov-report=html --cov-report term test
5150
displayName: PyTest
5251
5352
- task: PublishTestResults@2
@@ -57,3 +56,10 @@ jobs:
5756
testResultsFormat: "JUnit"
5857
testResultsFiles: ${{ format('$(System.DefaultWorkingDirectory)/unit_result.xml') }}
5958
testRunTitle: ${{ format('{0}_{1}_{2}', parameters.name, parameters.architecture, parameters.kind) }}
59+
60+
- ${{ if ne(parameters.kind, 'cython') }}:
61+
- task: PublishCodeCoverageResults@1
62+
inputs:
63+
codeCoverageTool: Cobertura
64+
summaryFileLocation: ${{ format('$(System.DefaultWorkingDirectory)/coverage.xml') }}
65+
reportDirectory: ${{ format('$(System.DefaultWorkingDirectory)/htmlcov') }}

.coveragerc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,36 @@ source =
33
advanced_descriptors
44
omit =
55
test/*
6+
branch = True
7+
[report]
8+
exclude_lines =
9+
# Have to re-enable the standard pragma
10+
pragma: no cover
11+
12+
# Don't complain about missing debug-only code:
13+
def __repr__
14+
15+
# Don't complain if tests don't hit defensive assertion code:
16+
raise NotImplementedError
17+
18+
# Exclude methods marked as abstract
19+
@abstractmethod
20+
21+
# Exclude import statements
22+
^from\b
23+
^import\b
24+
25+
# Exclude variable declarations that are executed when file is loaded
26+
^[a-zA-Z_]+\b\s=
27+
28+
# Code for static analysis is never covered:
29+
if typing.TYPE_CHECKING:
30+
31+
# Fallback code with no installed deps is almost impossible to cover properly
32+
except ImportError:
33+
34+
# Don't complain if non-runnable code isn't run:
35+
if __name__ == .__main__.:
36+
37+
# OS Specific
38+
if platform.system()

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
### Test results
22
/*_result*.xml
33
/report.html
4-
/assets/
4+
/assets/*
55
.cache/*
6-
.pytest_cache/
6+
.pytest_cache/*
7+
8+
### Generated version
9+
/advanced_descriptors/_version.py
710

811
### Generated code
912
/advanced_descriptors/*.c

.travis.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ _helpers:
4747

4848
script:
4949
- python setup.py develop -v
50-
- py.test -vv --cov-config .coveragerc --cov-report= --cov=advanced_descriptors test
50+
- py.test -vvv --cov-config .coveragerc --cov-report= --cov=advanced_descriptors test
5151
- coverage report -m --fail-under 89
5252
after_success:
5353
- coveralls
@@ -59,8 +59,9 @@ jobs:
5959
install:
6060
- *upgrade_python_toolset
6161
- *install_deps
62-
- pip install --upgrade "pylint > 2.3" isort[pyproject,requirements]
62+
- pip install --upgrade "pylint >= 2.3" isort[pyproject,requirements]
6363
script:
64+
- python setup.py --version
6465
- pylint advanced_descriptors
6566
- <<: *static_analysis
6667
name: "Bandit"
@@ -74,8 +75,9 @@ jobs:
7475
install:
7576
- *upgrade_python_toolset
7677
- *install_deps
77-
- pip install --upgrade "mypy >= 0.670"
78+
- pip install --upgrade "mypy >= 0.700"
7879
script:
80+
- python setup.py --version
7981
- mypy --strict advanced_descriptors
8082
- <<: *static_analysis
8183
name: "PEP8"

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2017-2018 Alexey Stepanov aka penguinolog
189+
Copyright 2017-2019 Alexey Stepanov aka penguinolog
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
include *.rst LICENSE requirements.txt pyproject.toml
1+
include *.rst LICENSE requirements.txt
2+
global-include *.pyx *.pxd
23
global-exclude *.c
34
exclude Makefile
45
prune tools

advanced_descriptors/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,17 @@
1313

1414
"""Advanced descriptors for special cases."""
1515

16-
import pkg_resources
17-
16+
# Local Implementation
1817
from .advanced_property import AdvancedProperty
1918
from .log_on_access import LogOnAccess
2019
from .separate_class_method import SeparateClassMethod
2120

2221
__all__ = ("SeparateClassMethod", "AdvancedProperty", "LogOnAccess")
2322

2423
try:
25-
__version__ = pkg_resources.get_distribution(__name__).version
26-
except pkg_resources.DistributionNotFound:
27-
# package is not installed, try to get from SCM
28-
try:
29-
import setuptools_scm # type: ignore
30-
31-
__version__ = setuptools_scm.get_version()
32-
except ImportError:
33-
setuptools_scm = None
24+
from ._version import version as __version__
25+
except ImportError:
26+
pass
3427

3528
__author__ = "Alexey Stepanov"
3629
__author_email__ = "[email protected]"

advanced_descriptors/advanced_property.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
__all__ = ("AdvancedProperty",)
1919

20+
# Standard Library
2021
import typing
2122

2223

advanced_descriptors/log_on_access.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
__all__ = ("LogOnAccess",)
1919

20+
# Standard Library
2021
import logging
2122
import sys
2223
import traceback

advanced_descriptors/separate_class_method.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
__all__ = ("SeparateClassMethod",)
1919

20+
# Standard Library
2021
import functools
2122
import typing
2223

0 commit comments

Comments
 (0)