diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..90a59d3 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,50 @@ +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events + push: + pull_request: + schedule: + - cron: '0 12 * * 0' # run once a week on Sunday + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + tests: + name: "Python ${{ matrix.python-version }}" + runs-on: "ubuntu-latest" + + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9", "pypy3"] + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: "actions/checkout@v2" + - uses: "actions/setup-python@v2" + with: + python-version: "${{ matrix.python-version }}" + - name: "Install dependencies" + run: | + set -xe + python -VV + python -m site + python -m pip install --upgrade pip setuptools wheel + python -m pip install --upgrade virtualenv tox tox-gh-actions + - name: "Run tox targets for ${{ matrix.python-version }}" + run: "python -m tox" + + - name: "Report to coveralls" + # coverage is only created in the py39 environment + # --service=github is a workaround for bug + # https://github.com/coveralls-clients/coveralls-python/issues/251 + if: "matrix.python-version == '3.9'" + run: | + pip install coveralls + coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 29bca3f..b1e335c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,15 @@ repos: - repo: https://github.com/psf/black - rev: stable + rev: 20.8b1 hooks: - id: black + args: [--line-length=80] + - repo: https://gitlab.com/pycqa/flake8 + rev: "3.8.4" + hooks: + - id: flake8 + - repo: https://github.com/asottile/pyupgrade + rev: v2.7.4 + hooks: + - id: pyupgrade + args: [--py36-plus] diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 622d714..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: python - -python: 3.8 - -cache: pip - -matrix: - include: - - python: "3.6" - env: TOXENV=py36 - - python: "3.7" - env: TOXENV=py37 - - python: "3.8" - env: TOXENV=py38 - - python: "3.8" - env: TOXENV=pep8 - - python: "3.8" - env: TOXENV=coverage -before_install: - - pip install --upgrade pip setuptools -install: - - pip install tox - - if [ "$TOXENV" = 'coverage' ]; then pip install coveralls; fi -script: - - tox -e $TOXENV -after_success: - - if [ "$TOXENV" = 'coverage' ]; then coveralls; fi diff --git a/CHANGES.rst b/CHANGES.rst index b1cb959..e98edfc 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,10 @@ CHANGES - Make Python 3.6 the default testing environment. +- Add support for Python 3.9. + +- Use GitHub Actios for CI. + 0.1 (2016-06-09) ================ diff --git a/README.rst b/README.rst index 0b27616..46891c2 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,18 @@ +.. image:: https://github.com/morepath/morepath_wiki/workflows/CI/badge.svg?branch=master + :target: https://github.com/morepath/morepath_wiki/actions?workflow=CI + :alt: CI Status + +.. image:: https://coveralls.io/repos/github/morepath/morepath_wiki/badge.svg?branch=master + :target: https://coveralls.io/github/morepath/morepath_wiki?branch=master + +.. image:: https://img.shields.io/pypi/v/morepath_wiki.svg + :target: https://pypi.org/project/morepath_wiki/ + +.. image:: https://img.shields.io/pypi/pyversions/morepath_wiki.svg + :target: https://pypi.org/project/morepath_wiki/ + + + Morepath Wiki ============= @@ -60,4 +75,4 @@ And to run the test suite:: .. _GitHub: https://github.com/morepath/morepath_wiki -.. _virtual environment: http://www.virtualenv.org/ +.. _virtual environment: https://virtualenv.pypa.io/en/latest/ diff --git a/morepath_wiki/html.py b/morepath_wiki/html.py index ab4c21e..efb04ee 100644 --- a/morepath_wiki/html.py +++ b/morepath_wiki/html.py @@ -1,4 +1,3 @@ -# -*- encoding: utf8 -*- # # $Id: html.py 5409 2011-06-29 07:07:25Z rjones $ # $HeadURL: svn+ssh://svn/svn/trunk/api/eklib/html.py $ @@ -223,7 +222,6 @@ See the end of the source file for the license of use. XHTML support was contributed by Michael Haubenwallner. """ -from __future__ import with_statement __version__ = "1.16" @@ -232,7 +230,7 @@ import unittest -class HTML(object): +class HTML: """Easily generate HTML. >>> print HTML('html', 'some text') @@ -254,7 +252,9 @@ class HTML(object): newline_default_on = set("table ol ul dl".split()) - def __init__(self, name=None, text=None, stack=None, newlines=True, escape=True): + def __init__( + self, name=None, text=None, stack=None, newlines=True, escape=True + ): self._name = name self._content = [] self._attrs = {} @@ -311,10 +311,13 @@ def __call__(self, *content, **kw): if self._name == "read": if len(content) == 1 and isinstance(content[0], int): raise TypeError( - "you appear to be calling read(%d) on " "a HTML instance" % content + "you appear to be calling read(%d) on " + "a HTML instance" % content ) elif len(content) == 0: - raise TypeError("you appear to be calling read() on a " "HTML instance") + raise TypeError( + "you appear to be calling read() on a " "HTML instance" + ) # customising a tag with content or attributes escape = kw.pop("escape", True) @@ -343,7 +346,7 @@ def __exit__(self, exc_type, exc_value, exc_tb): self._stack.pop() def __repr__(self): - return "" % (self._name, id(self)) + return "".format(self._name, id(self)) def _stringify(self, str_type): # turn me and my content into text @@ -352,7 +355,7 @@ def _stringify(self, str_type): return join.join(map(str_type, self._content)) a = ['%s="%s"' % i for i in self._attrs.items()] l = [self._name] + a - s = "<%s>%s" % (" ".join(l), join) + s = "<{}>{}".format(" ".join(l), join) if self._content: s += join.join(map(str_type, self._content)) s += join + "" % self._name @@ -384,12 +387,12 @@ def _stringify(self, str_type): return join.join(map(str_type, self._content)) a = ['%s="%s"' % i for i in self._attrs.items()] l = [self._name] + a - s = "<%s>%s" % (" ".join(l), join) + s = "<{}>{}".format(" ".join(l), join) if self._content or not (self._name.lower() in self.empty_elements): s += join.join(map(str_type, self._content)) s += join + "" % self._name else: - s = "<%s />%s" % (" ".join(l), join) + s = "<{} />{}".format(" ".join(l), join) return s @@ -409,12 +412,12 @@ def _stringify(self, str_type): return join.join(map(str_type, self._content)) a = ['%s="%s"' % i for i in self._attrs.items()] l = [self._name] + a - s = "<%s>%s" % (" ".join(l), join) + s = "<{}>{}".format(" ".join(l), join) if self._content: s += join.join(map(str_type, self._content)) s += join + "" % self._name else: - s = "<%s />%s" % (" ".join(l), join) + s = "<{} />{}".format(" ".join(l), join) return s @@ -443,7 +446,8 @@ def test_iadd_tag(self): h += XML("some-tag", "spam", newlines=False) h += XML("text", "spam", newlines=False) self.assertEquals( - str(h), "\nspam\nspam\n" + str(h), + "\nspam\nspam\n", ) def test_iadd_text(self): @@ -523,7 +527,9 @@ def test_subtag_direct(self): l = h.ol l.li("foo") l.li.b("bar") - self.assertEquals(str(h), "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
") + self.assertEquals( + str(h), "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
" + ) def test_subtag_direct_context(self): 'generation of sub-tags directly on the parent tag in "with" context' @@ -531,7 +537,9 @@ def test_subtag_direct_context(self): with h.ol as l: l.li("foo") l.li.b("bar") - self.assertEquals(str(h), "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
") + self.assertEquals( + str(h), "
    \n
  1. foo
  2. \n
  3. bar
  4. \n
" + ) def test_subtag_no_newlines(self): "prevent generation of newlines against default" diff --git a/morepath_wiki/model.py b/morepath_wiki/model.py index ca76b69..d3c817b 100644 --- a/morepath_wiki/model.py +++ b/morepath_wiki/model.py @@ -1,7 +1,7 @@ -class Root(object): +class Root: pass -class Page(object): +class Page: def __init__(self, name): self.name = name diff --git a/morepath_wiki/storage.py b/morepath_wiki/storage.py index 98493d3..31630e5 100644 --- a/morepath_wiki/storage.py +++ b/morepath_wiki/storage.py @@ -15,7 +15,7 @@ def wikify(text): return wikiname_re.sub(r'\1', py_html.escape(text)) -class Storage(object): +class Storage: def __init__(self, directory): self.directory = directory diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index b38ecf7..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,16 +0,0 @@ -[tool.black] -line-length = 80 -target-version = ['py36', 'py37', 'py38'] -include = '\.pyi?$' -exclude = ''' -( - /( - \.git - | \.tox - | env - | build - | dist - )/ - | morepath_wiki/html.py -) -''' diff --git a/setup.py b/setup.py index 1208412..493be1b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- - -import io from setuptools import setup, find_packages @@ -12,9 +9,9 @@ "web micro-framework battle by Richard Jones" ), long_description=( - io.open("README.rst", encoding="utf-8").read() + open("README.rst", encoding="utf-8").read() + "\n\n" - + io.open("CHANGES.rst", encoding="utf-8").read() + + open("CHANGES.rst", encoding="utf-8").read() ), author="Morepath developers", author_email="morepath@googlegroups.com", @@ -30,7 +27,6 @@ ], extras_require=dict( test=["pytest >= 2.9.0", "webtest", "pytest-remove-stale-bytecode"], - pep8=["flake8", "black"], coverage=["pytest-cov"], ), entry_points={ @@ -44,5 +40,6 @@ "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", ], ) diff --git a/tox.ini b/tox.ini index 2ef1306..935d19a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,5 @@ [tox] -envlist = py36, py37, py38, pypy3, coverage, pep8 -skipsdist = True +envlist = py36, py37, py38, py39, pypy3, coverage, pre-commit skip_missing_interpreters = True [testenv] @@ -9,19 +8,27 @@ extras = test commands = pytest {posargs} -[testenv:pep8] -basepython = python3.8 -extras = pep8 - -commands = flake8 morepath_wiki setup.py - black --check morepath_wiki setup.py +[testenv:pre-commit] +deps = pre-commit +commands = pre-commit run --all-files [testenv:coverage] -basepython = python3.8 +basepython = python3 extras = test coverage commands = pytest --cov morepath_wiki --cov-fail-under=100 {posargs} +[gh-actions] +python = + 3.6: py36 + 3.7: py37 + 3.8: py38 + 3.9: py39, pre-commit, mypy, coverage + [flake8] +max-line-length = 88 +ignore = + E231 # clashes with black + W503 exclude = morepath_wiki/html.py