Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Python versions to 3.8 through 3.12 #127

Merged
merged 3 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: python3.8 -m pip install flake8 mypy
- name: Lint
run: |
flake8 --max-complexity=10 penman/
mypy penman/
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: python3.8 -m pip install flake8 mypy
- name: Lint
run: |
flake8 --max-complexity=10 penman/
mypy penman/

tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
os: [ubuntu-latest, windows-latest]
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install pytest
- name: Test
run: pytest --doctest-glob=\*.rst --doctest-modules --ignore-glob=penman/interface.py
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: python -m pip install pytest
- name: Test
run: pytest --doctest-glob=\*.rst --doctest-modules --ignore-glob=penman/interface.py
32 changes: 16 additions & 16 deletions .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "setuptools >= 38.6.0" "wheel >= 0.31.0" "twine >= 1.11.0"
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "setuptools >= 38.6.0" "wheel >= 0.31.0" "twine >= 1.11.0"
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

## [Unreleased]

### Python Versions

* Removed support for Python 3.6
* Removed support for Python 3.7
* Added support for Python 3.10
* Added support for Python 3.11
* Added support for Python 3.12


## [v1.2.2]

**Release date: 2022-09-01**
Expand Down
4 changes: 2 additions & 2 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ source code.
Requirements
------------

The Penman package runs with `Python 3.6`_ and higher versions, but
The Penman package runs with `Python 3.8`_ and higher versions, but
otherwise it has no dependencies beyond Python's standard library.

Some development tasks, such as unit testing, building the
Expand Down Expand Up @@ -105,7 +105,7 @@ Style-checking with Flake8

.. _PyPI: https://pypi.org/project/Penman/
.. _GitHub: https://github.com/goodmami/penman/
.. _Python 3.6: https://www.python.org/
.. _Python 3.8: https://www.python.org/
.. _virtual environment: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
.. _pytest: http://pytest.org/
.. _tox: https://tox.readthedocs.io/en/latest/
Expand Down
4 changes: 2 additions & 2 deletions penman/_lexer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Classes and functions for lexing PENMAN strings.
"""

from typing import Union, Iterable, Iterator, NamedTuple, Pattern
from typing import Union, Iterable, Iterator, NamedTuple, Pattern, Optional
import re
import logging

Expand Down Expand Up @@ -159,7 +159,7 @@ def error(self, message: str, token=None) -> DecodeError:


def lex(lines: Union[Iterable[str], str],
pattern: Union[Pattern[str], str] = None) -> TokenIterator:
pattern: Optional[Union[Pattern[str], str]] = None) -> TokenIterator:
"""
Yield PENMAN tokens matched in *lines*.

Expand Down
20 changes: 10 additions & 10 deletions penman/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class PENMANCodec(object):
An encoder/decoder for PENMAN-serialized graphs.
"""

def __init__(self, model: Model = None):
def __init__(self, model: Optional[Model] = None):
if model is None:
model = Model()
self.model = model
Expand Down Expand Up @@ -105,7 +105,7 @@ def parse_triples(self, s: str) -> List[BasicTriple]:

def encode(self,
g: Graph,
top: Variable = None,
top: Optional[Variable] = None,
indent: Union[int, None] = -1,
compact: bool = False) -> str:
"""
Expand Down Expand Up @@ -168,7 +168,7 @@ def format_triples(self,
# public API.

def _decode(s: str,
model: Model = None) -> Graph:
model: Optional[Model] = None) -> Graph:
"""
Deserialize PENMAN-serialized *s* into its Graph object

Expand All @@ -188,7 +188,7 @@ def _decode(s: str,


def _iterdecode(lines: Union[Iterable[str], str],
model: Model = None) -> Iterator[Graph]:
model: Optional[Model] = None) -> Iterator[Graph]:
"""
Yield graphs parsed from *lines*.

Expand All @@ -210,8 +210,8 @@ def _iterdecode(lines: Union[Iterable[str], str],


def _encode(g: Graph,
top: Variable = None,
model: Model = None,
top: Optional[Variable] = None,
model: Optional[Model] = None,
indent: Union[int, bool] = -1,
compact: bool = False) -> str:
"""
Expand Down Expand Up @@ -240,7 +240,7 @@ def _encode(g: Graph,


def _load(source: FileOrFilename,
model: Model = None,
model: Optional[Model] = None,
encoding: Optional[str] = None) -> List[Graph]:
"""
Deserialize a list of PENMAN-encoded graphs from *source*.
Expand All @@ -261,7 +261,7 @@ def _load(source: FileOrFilename,


def _loads(string: str,
model: Model = None) -> List[Graph]:
model: Optional[Model] = None) -> List[Graph]:
"""
Deserialize a list of PENMAN-encoded graphs from *string*.

Expand All @@ -277,7 +277,7 @@ def _loads(string: str,

def _dump(graphs: Iterable[Graph],
file: FileOrFilename,
model: Model = None,
model: Optional[Model] = None,
indent: Union[int, bool] = -1,
compact: bool = False,
encoding: Optional[str] = None) -> None:
Expand Down Expand Up @@ -314,7 +314,7 @@ def _dump_stream(fh, gs, codec, indent, compact):


def _dumps(graphs: Iterable[Graph],
model: Model = None,
model: Optional[Model] = None,
indent: Union[int, bool] = -1,
compact: bool = False) -> str:
"""
Expand Down
12 changes: 7 additions & 5 deletions penman/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-

from typing import Optional


class PenmanError(Exception):
"""Base class for errors in the Penman package."""
Expand All @@ -21,11 +23,11 @@ class DecodeError(PenmanError):
"""Raised on PENMAN syntax errors."""

def __init__(self,
message: str = None,
filename: str = None,
lineno: int = None,
offset: int = None,
text: str = None):
message: Optional[str] = None,
filename: Optional[str] = None,
lineno: Optional[int] = None,
offset: Optional[int] = None,
text: Optional[str] = None):
self.message = message
self.filename = filename
self.lineno = lineno
Expand Down
16 changes: 8 additions & 8 deletions penman/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class Graph(object):
"""

def __init__(self,
triples: Triples = None,
top: Variable = None,
epidata: Mapping[BasicTriple, Epidata] = None,
metadata: Mapping[str, str] = None):
triples: Optional[Triples] = None,
top: Optional[Variable] = None,
epidata: Optional[Mapping[BasicTriple, Epidata]] = None,
metadata: Optional[Mapping[str, str]] = None):
if not triples:
triples = []
if not epidata:
Expand Down Expand Up @@ -207,8 +207,8 @@ def instances(self) -> List[Instance]:

def edges(self,
source: Optional[Variable] = None,
role: Role = None,
target: Variable = None) -> List[Edge]:
role: Optional[Role] = None,
target: Optional[Variable] = None) -> List[Edge]:
"""
Return edges filtered by their *source*, *role*, or *target*.

Expand All @@ -221,8 +221,8 @@ def edges(self,

def attributes(self,
source: Optional[Variable] = None,
role: Role = None,
target: Constant = None) -> List[Attribute]:
role: Optional[Role] = None,
target: Optional[Constant] = None) -> List[Attribute]:
"""
Return attributes filtered by their *source*, *role*, or *target*.

Expand Down
18 changes: 9 additions & 9 deletions penman/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
('b', ':ARG0', 'd')] : POP
"""

from typing import Union, Mapping, Callable, Any, List, Set, cast
from typing import Union, Mapping, Callable, Any, List, Set, cast, Optional
import copy
import logging

Expand Down Expand Up @@ -103,7 +103,7 @@ def __repr__(self):

# Tree to graph interpretation ################################################

def interpret(t: Tree, model: Model = None) -> Graph:
def interpret(t: Tree, model: Optional[Model] = None) -> Graph:
"""
Interpret tree *t* as a graph using *model*.

Expand Down Expand Up @@ -228,8 +228,8 @@ def _process_atomic(target):
# Graph to tree configuration #################################################

def configure(g: Graph,
top: Variable = None,
model: Model = None) -> Tree:
top: Optional[Variable] = None,
model: Optional[Model] = None) -> Tree:
"""
Create a tree from a graph by making as few decisions as possible.

Expand Down Expand Up @@ -311,7 +311,7 @@ def _configure(g, top, model):
if len(g.triples) == 0:
return (g.top, []), [], {}

nodemap: _Nodemap = {var: None for var in g.variables()}
nodemap: _Nodemap = {var: None for var in g.variables()} # type: ignore
if top is None:
top = g.top
if top not in nodemap:
Expand Down Expand Up @@ -479,9 +479,9 @@ def _process_epigraph(node):


def reconfigure(g: Graph,
top: Variable = None,
model: Model = None,
key: Callable[[Role], Any] = None) -> Tree:
top: Optional[Variable] = None,
model: Optional[Model] = None,
key: Optional[Callable[[Role], Any]] = None) -> Tree:
"""
Create a tree from a graph after any discarding layout markers.

Expand All @@ -503,7 +503,7 @@ def _key(triple):


def rearrange(t: Tree,
key: Callable[[Role], Any] = None,
key: Optional[Callable[[Role], Any]] = None,
attributes_first: bool = False) -> None:
"""
Sort the branches at each node in tree *t* according to *key*.
Expand Down
8 changes: 4 additions & 4 deletions penman/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def __init__(self,
top_variable: Variable = 'top',
top_role: Role = ':TOP',
concept_role: Role = CONCEPT_ROLE,
roles: Mapping[Role, Any] = None,
normalizations: Mapping[Role, Role] = None,
reifications: Iterable[_ReificationSpec] = None):
roles: Optional[Mapping[Role, Any]] = None,
normalizations: Optional[Mapping[Role, Role]] = None,
reifications: Optional[Iterable[_ReificationSpec]] = None):
self.top_variable = top_variable
self.top_role = top_role
self.concept_role = concept_role
Expand Down Expand Up @@ -194,7 +194,7 @@ def is_role_reifiable(self, role: Role) -> bool:

def reify(self,
triple: BasicTriple,
variables: Set[Variable] = None) -> _Reification:
variables: Optional[Set[Variable]] = None) -> _Reification:
"""
Return the three triples that reify *triple*.

Expand Down
4 changes: 2 additions & 2 deletions penman/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Surface strings, tokens, and alignments.
"""

from typing import TypeVar, Type, Mapping, Tuple
from typing import TypeVar, Type, Mapping, Tuple, Optional

from penman.types import BasicTriple
from penman.graph import Graph
Expand All @@ -19,7 +19,7 @@ class AlignmentMarker(Epidatum):

__slots__ = 'indices', 'prefix',

def __init__(self, indices: Tuple[int, ...], prefix: str = None):
def __init__(self, indices: Tuple[int, ...], prefix: Optional[str] = None):
super().__init__()
self.indices = indices
self.prefix = prefix
Expand Down
Loading
Loading