Skip to content

Commit 96917b3

Browse files
authored
Add func.__version__ dunder method (PEP 440) (#54)
* Add func.__version__ field in library * Change version back to 1.2.0
1 parent ec32839 commit 96917b3

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

azure/functions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,5 @@
4646
# Middlewares
4747
'WsgiMiddleware',
4848
)
49+
50+
__version__ = '1.2.0'

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from setuptools import setup
2+
from azure.functions import __version__
23

34

45
setup(
56
name='azure-functions',
6-
version='1.2.0',
7+
version=__version__,
78
description='Azure Functions for Python',
89
author='Microsoft Corporation',
910
author_email='[email protected]',

tests/test_code_quality.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import subprocess
33
import sys
44
import unittest
5+
import re
6+
import azure.functions as func
57

68

79
ROOT_PATH = pathlib.Path(__file__).parent.parent
@@ -47,3 +49,11 @@ def test_flake8(self):
4749
output = ex.output.decode()
4850
raise AssertionError(
4951
f'flake8 validation failed:\n{output}') from None
52+
53+
def test_library_version(self):
54+
# PEP 440 Parsing version strings with regular expressions
55+
is_valid = re.match(
56+
r'^([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))'
57+
r'*((a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))'
58+
r'?(\.dev(0|[1-9][0-9]*))?$', func.__version__) is not None
59+
self.assertTrue(is_valid, '__version__ field must be canonical')

0 commit comments

Comments
 (0)