Skip to content

Commit

Permalink
Merge pull request #329 from BCG-Gamma/dev/2.0.0
Browse files Browse the repository at this point in the history
BUILD: Release pytools 2.0.0
  • Loading branch information
j-ittner authored Jun 10, 2022
2 parents 30b4bf3 + 2af5e18 commit 980e221
Show file tree
Hide file tree
Showing 38 changed files with 709 additions and 456 deletions.
12 changes: 7 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 22.1.0
rev: 22.3.0
hooks:
- id: black
language_version: python3
Expand All @@ -17,7 +17,8 @@ repos:
name: flake8
entry: flake8 --config tox.ini
language: python_venv
additional_dependencies: [ flake8-comprehensions, flake8-import-order ]
additional_dependencies:
- flake8-comprehensions ~= 3.10
types: [ python ]

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand All @@ -28,8 +29,9 @@ repos:
- id: check-yaml

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: v0.961
hooks:
- id: mypy
files: src/
additional_dependencies: [ numpy>=1.22 ]
files: src|sphinx
additional_dependencies:
- numpy~=1.22
10 changes: 9 additions & 1 deletion RELEASE_NOTES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,21 @@ and is now subject to static type checking with :mod:`mypy`.

- API: improved conversion of :mod:`numpy` arrays to :class:`.Expression` objects in
function :func:`.make_expression`
- API: remove method ``get_class_id`` from class :class:`.HasExpressionRepr`
- API: removed method ``get_class_id`` from class :class:`.HasExpressionRepr`

``pytools.fit``
^^^^^^^^^^^^^^^

- API: method :meth:`.FittableMixin.ensure_fitted` is now public, replacing the formerly
private method ``_ensure_fitted()``

``pytools.meta``
^^^^^^^^^^^^^^^^

- API: removed function ``compose_meta`` due to conflicts with *mypy* static type checks
- API: new metaclass :class:`.SingletonABCMeta` combining :class:`.SingletonMeta` and
:class:`~abc.ABCMeta`

``pytools.parallelization``
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand All @@ -54,6 +61,7 @@ and is now subject to static type checking with :mod:`mypy`.
:meth:`.JobQueue.aggregate`
- API: :class:`.SimpleQueue` is now an abstract class, expecting subclasses to implement
method :meth:`.SimpleQueue.aggregate`
- API: renamed class ``NestedQueue`` to :class:`.CompositeQueue`

``pytools.sphinx``
^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ stages:
versionSpec: '3.8'
displayName: 'use Python 3.8'
- script: |
python -m pip install black==22.1
python -m pip install black==22.3
python -m black --check .
displayName: 'Run black'
- job:
Expand Down
6 changes: 3 additions & 3 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dependencies:
- scipy ~= 1.8
- typing_inspect ~= 0.7
# build/test
- black ~= 22.1
- black ~= 22.3
- conda-build ~= 3.21
- conda-verify ~= 3.1
- docutils ~= 0.17
Expand All @@ -28,14 +28,14 @@ dependencies:
- pytest ~= 5.4
- pytest-cov ~= 2.12
- pyyaml ~= 5.4
- sphinx ~= 4.2
- sphinx ~= 4.4
- sphinx-autodoc-typehints ~= 1.12
- toml ~= 0.10
- tox ~= 3.24
- yaml ~= 0.2
# notebooks
- jupyterlab ~= 3.2
- nbclassic ~= 0.3
- nbsphinx ~= 0.7.1
- nbsphinx ~= 0.8.8
- openpyxl ~= 3.0
- seaborn ~= 0.11
3 changes: 2 additions & 1 deletion sphinx/base/conf_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def set_config(
intersphinx_mapping = {
"pandas": ("https://pandas.pydata.org/pandas-docs/stable", None),
"pd": ("https://pandas.pydata.org/pandas-docs/stable", None),
"matplotlib": ("https://matplotlib.org", None),
"matplotlib": ("https://matplotlib.org/stable", None),
"numpy": ("https://numpy.org/doc/stable", None),
"np": ("https://numpy.org/doc/stable", None),
"python": ("https://docs.python.org/3.7", None),
Expand Down Expand Up @@ -162,6 +162,7 @@ def set_config(
set_type_checking_flag = False
typehints_fully_qualified = False
always_document_param_types = False
autodoc_typehints_format = "short"

# -- Options for Math output -----------------------------------------------------------

Expand Down
14 changes: 5 additions & 9 deletions sphinx/base/make_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"""
Sphinx documentation build script
"""
from __future__ import annotations

import json
import os
import re
Expand All @@ -11,7 +13,7 @@
from abc import ABCMeta, abstractmethod
from glob import glob
from tempfile import TemporaryDirectory
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple, Type, TypeVar
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
from weakref import ref

from make_util import get_package_version as _get_package_version
Expand Down Expand Up @@ -51,10 +53,6 @@
# noinspection SpellCheckingInspection
ENV_PYTHON_PATH = "PYTHONPATH"

# regex pattern to match the version declaration in a top-level __init__.py

T = TypeVar("T")


class CommandMeta(ABCMeta):
"""
Expand All @@ -67,7 +65,7 @@ def __init__(cls, *args: Any, **kwargs: Any) -> None:
super().__init__(*args, **kwargs)
cls.__instance_ref: Optional[ref] = None

def __call__(cls: Type[T], *args, **kwargs: Any) -> T:
def __call__(cls, *args, **kwargs: Any) -> CommandMeta:
"""
Return the existing command instance, or create a new one if none exists yet.
Expand All @@ -76,8 +74,6 @@ def __call__(cls: Type[T], *args, **kwargs: Any) -> T:
if args or kwargs:
raise ValueError("command classes may not take any arguments")

cls: CommandMeta

if cls.__instance_ref:
obj = cls.__instance_ref()
if obj is not None:
Expand Down Expand Up @@ -111,7 +107,7 @@ def get_prerequisites(self) -> Iterable["Command"]:
dependencies_inherited = dependency.get_dependencies()
if self in dependencies_inherited:
raise ValueError(
f"circular dependency: {dependency.name} " f"depends on {self.name}"
f"circular dependency: {dependency.name} depends on {self.name}"
)
dependencies_extended.extend(
dependency
Expand Down
4 changes: 2 additions & 2 deletions sphinx/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ def make() -> None:
),
)
# noinspection PyUnresolvedReferences
from make_base import make
from make_base import make as make_

make(modules=["pytools"])
make_(modules=["pytools"])


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion src/pytools/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""
A collection of Python extensions and tools used in BCG GAMMA's open-source libraries.
"""
__version__ = "2.0.dev8"
__version__ = "2.0.0"
10 changes: 5 additions & 5 deletions src/pytools/api/_alltracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class AllTracker:
definitions for being exported:
- constant definitions should not be exported, as this will pose difficulties
with Sphinx documentation and - from a design perspective - provides less context
than defining constants inside classes
with Sphinx documentation and - from an API design perspective - provides less
context than defining constants inside classes
- definitions exported from other modules should not be re-exported by the importing
module
Expand Down Expand Up @@ -99,8 +99,8 @@ def __init__(
allow_imported_definitions: bool = False,
) -> None:
"""
:param globals_: the dictionary of global variables returned by calling
:meth:`._globals` in the current module scope
:param globals_: the dictionary of global variables obtained by calling
:meth:`.globals` in the current module scope
:param public_module: full name of the public module that will export the items
managed by this tracker
:param update_forward_references: if ``True``, automatically replace all forward
Expand Down Expand Up @@ -310,7 +310,7 @@ def _update(_obj: Any, local_ns: Optional[Dict[str, Any]] = None) -> None:
if isinstance(_obj, type):
if _obj not in visited:
visited.add(_obj)
local_ns = _obj.__dict__
local_ns = dict(_obj.__dict__)
for member in vars(_obj).values():
_update(member, local_ns=local_ns)
_update_annotations(_obj, local_ns)
Expand Down
Loading

0 comments on commit 980e221

Please sign in to comment.