Skip to content

Commit

Permalink
Merge branch 'trunk' into 8-make-more-analysis-tooling
Browse files Browse the repository at this point in the history
  • Loading branch information
glyph authored Jun 16, 2022
2 parents daddf4f + 4260ebb commit bc46e6e
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 33 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: ci

on:
push:
branches:
- trunk

pull_request:
branches:
- trunk

jobs:
build:
name: ${{ matrix.TOX_ENV }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.10"]
TOX_ENV: ["py310-extras", "py310-noextras", "mypy"]

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python }}
- name: Tox Run
run: |
pip install tox;
TOX_ENV="${{ matrix.TOX_ENV }}";
echo "Starting: ${TOX_ENV} ${PUSH_DOCS}"
if [[ -n "${TOX_ENV}" ]]; then
tox -e "$TOX_ENV";
if [[ "${TOX_ENV}" != "mypy" ]]; then
tox -e coverage-report;
fi;
fi;
- name: Upload coverage report
if: ${{ matrix.TOX_ENV != 'mypy' }}
uses: codecov/[email protected]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ values initialized, because they have to be called in the order you declare
them.

You can read about state machines and their advantages for Python programmers
in considerably more detail
[in this excellent series of articles from ClusterHQ](https://clusterhq.com/blog/what-is-a-state-machine/).
in more detail [in this excellent article by Jean-Paul
Calderone](https://web.archive.org/web/20160507053658/https://clusterhq.com/2013/12/05/what-is-a-state-machine/).

### What makes Automat different? ###

Expand Down
3 changes: 2 additions & 1 deletion automat/_introspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@


def copycode(template, changes):
if hasattr(code, "replace"):
return template.replace(**{"co_" + k : v for k, v in changes.items()})
names = [
"argcount", "nlocals", "stacksize", "flags", "code", "consts",
"names", "varnames", "filename", "name", "firstlineno", "lnotab",
Expand All @@ -23,7 +25,6 @@ def copycode(template, changes):
return code(*values)



def copyfunction(template, funcchanges, codechanges):
names = [
"globals", "name", "defaults", "closure",
Expand Down
16 changes: 5 additions & 11 deletions automat/_methodical.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@
from functools import wraps
from itertools import count

try:
# Python 3
from inspect import getfullargspec as getArgsSpec
except ImportError:
# Python 2
from inspect import getargspec as getArgsSpec
from inspect import getfullargspec as getArgsSpec

import attr
import six

from ._core import Transitioner, Automaton
from ._introspection import preserveName
Expand All @@ -36,14 +30,14 @@ def _getArgSpec(func):
return ArgSpec(
args=tuple(spec.args),
varargs=spec.varargs,
varkw=spec.varkw if six.PY3 else spec.keywords,
varkw=spec.varkw,
defaults=spec.defaults if spec.defaults else (),
kwonlyargs=tuple(spec.kwonlyargs) if six.PY3 else (),
kwonlyargs=tuple(spec.kwonlyargs),
kwonlydefaults=(
tuple(spec.kwonlydefaults.items())
if spec.kwonlydefaults else ()
) if six.PY3 else (),
annotations=tuple(spec.annotations.items()) if six.PY3 else (),
),
annotations=tuple(spec.annotations.items()),
)


Expand Down
5 changes: 1 addition & 4 deletions automat/_test/test_discover.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
import tempfile
from unittest import skipIf, TestCase

import six


def isTwistedInstalled():
try:
__import__('twisted')
Expand Down Expand Up @@ -43,7 +40,7 @@ def tearDown(self):
super(_WritesPythonModules, self).tearDown()

sys.path[:] = self.savedSysPath
modulesToDelete = six.viewkeys(sys.modules) - self.originalSysModules
modulesToDelete = sys.modules.keys() - self.originalSysModules
for module in modulesToDelete:
del sys.modules[module]

Expand Down
3 changes: 3 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[mypy]
[mypy-graphviz.*]
ignore_missing_imports = True
12 changes: 2 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,19 @@

from setuptools import setup, find_packages

try:
from m2r import parse_from_file
long_description = parse_from_file('README.md')
except(IOError, ImportError):
print("\n\n!!! m2r not found, long_description is bad, don't upload this to PyPI !!!\n\n")
import io
long_description = io.open('README.md', encoding="utf-8").read()

setup(
name='Automat',
use_scm_version=True,
url='https://github.com/glyph/Automat',
description="""
Self-service finite-state machines for the programmer on the go.
""".strip(),
long_description=long_description,
readme='README.md',
packages=find_packages(exclude=[]),
package_dir={'automat': 'automat'},
setup_requires=[
'wheel',
'setuptools-scm',
'm2r',
],
install_requires=[
"attrs>=19.2.0",
Expand Down
24 changes: 19 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = coverage-clean,{pypy3,py35,py36,py38}-{extras,noextras},coverage-report
envlist = lint,mypy,coverage-clean,{pypy3,py38,py310}-{extras,noextras},coverage-report

[testenv]
deps =
Expand All @@ -10,30 +10,44 @@ deps =

commands =
coverage run --parallel --source automat -m py.test automat/_test
depends =
coverage-clean

[testenv:coverage-clean]
deps = coverage
skip_install = true
commands = coverage erase
depends =

[testenv:coverage-report]
deps = coverage
skip_install = true
commands =
coverage combine
coverage xml
coverage report -m
depends =
{pypy3,py38,py310}-{extras,noextras}

[testenv:benchmark]
deps = pytest-benchmark
commands = pytest --benchmark-only benchmark/

[testenv:py35-benchmark]
[testenv:py310-benchmark]
deps = {[testenv:benchmark]deps}
commands = {[testenv:benchmark]commands}

[testenv:py36-benchmark]
deps = {[testenv:benchmark]deps}
commands = {[testenv:benchmark]commands}
[testenv:lint]
deps = black
commands = black --check automat

[testenv:mypy]
deps =
mypy
graphviz>=0.4.9
Twisted>=16.2.0

commands = mypy automat

[testenv:pypy3-benchmark]
deps = {[testenv:benchmark]deps}
Expand Down

0 comments on commit bc46e6e

Please sign in to comment.