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

Class Decorator API #84

Merged
merged 7 commits into from Jan 12, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/qa.yaml
Expand Up @@ -6,19 +6,29 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Set up Node.js @latest
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install the world
run: |
python -m pip install --upgrade pip
pip install -r requirements_test.txt
python -m pip install --upgrade pip wheel
pip install -r requirements.txt
pip install -r requirements_dev.txt
pip install -e .
npm i
- name: Run linting
run: |
make lint
- name: Run type checking
run: |
make check
- name: Run tests
run: make test
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -11,3 +11,5 @@ pyee.egg-info/
version.txt
scratchpad.ipynb
.tox/
node_modules
venv
14 changes: 0 additions & 14 deletions .travis.yml

This file was deleted.

26 changes: 21 additions & 5 deletions DEVELOPMENT.rst
Expand Up @@ -4,23 +4,39 @@ Development And Publishing
Environment Setup
-----------------

To create a local virtualenv, run::

make setup

This will create a virtualenv at ``./venv``, install dependencies with pip,
and install pyright using npm.

To activate the environment in your shell::

. ./venv/bin/activate

Alternately, run everything with the make tasks, which source the activate
script before running commands.

conda
~~~~~

To create your environment, run::
To create a Conda environment, run::

conda env create
npm i

To update the environment, run::

conda env update
npm i --update

pip/virtualenv
~~~~~~~~~~~~~~
To activate the environment, run::

Create/activate your virtualenv and then run::
conda activate pyee

pip install -r requirements_dev.txt
The other Makefile tasks should operate normally if the environment is
activated.

Formatting, Linting and Testing
-------------------------------
Expand Down
40 changes: 24 additions & 16 deletions Makefile
@@ -1,34 +1,42 @@
init:
conda env create
.PHONY: setup setup-conda package upload check test tox lint format build_docs serve_docs clean

update:
conda env update
setup:
python3 -m venv venv
if [ -d venv ]; then . ./venv/bin/activate; fi; pip install pip wheel --upgrade
if [ -d venv ]; then . ./venv/bin/activate; fi; pip install -r requirements.txt
if [ -d venv ]; then . ./venv/bin/activate; fi; pip install -r requirements_dev.txt
if [ -d venv ]; then . ./venv/bin/activate; fi; pip install -e .
npm i

package:
python setup.py check
python setup.py sdist
python setup.py bdist_wheel --universal
package: test lint
if [ -d venv ]; then . ./venv/bin/activate; fi; python setup.py check
if [ -d venv ]; then . ./venv/bin/activate; fi; python setup.py sdist
if [ -d venv ]; then . ./venv/bin/activate; fi; python setup.py bdist_wheel --universal

upload:
twine upload dist/*
if [ -d venv ]; then . ./venv/bin/activate; fi; twine upload dist/*

test: lint
pytest ./tests
check:
if [ -d venv ]; then . ./venv/bin/activate; fi; npm run pyright

test:
if [ -d venv ]; then . ./venv/bin/activate; fi; pytest ./tests

tox:
tox
if [ -d venv ]; then . ./venv/bin/activate; fi; tox

lint:
flake8
if [ -d venv ]; then . ./venv/bin/activate; fi; flake8 ./pyee setup.py ./tests ./docs

format:
black ./pyee setup.py ./tests ./docs
if [ -d venv ]; then . ./venv/bin/activate; fi; black ./pyee setup.py ./tests ./docs
if [ -d venv ]; then . ./venv/bin/activate; fi; isort ./pyee setup.py ./tests ./docs

build_docs:
cd docs && make html
if [ -d venv ]; then . ./venv/bin/activate; fi; cd docs && make html

serve_docs:
cd docs/_build/html && python -m http.server
if [ -d venv ]; then . ./venv/bin/activate; fi; cd docs/_build/html && python -m http.server

clean:
rm -rf .tox
Expand Down
4 changes: 4 additions & 0 deletions docs/index.rst
Expand Up @@ -43,6 +43,10 @@ API Docs:

.. autofunction:: pyee.uplift.uplift

.. autofunction:: pyee.cls.on

.. autofunction:: pyee.cls.evented


Some Links
==========
Expand Down
37 changes: 37 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package.json
@@ -0,0 +1,22 @@
{
"name": "pyee-devtools",
"version": "1.0.0",
"description": "Node.js tools to support developing pyee",
"main": "index.js",
"scripts": {
"pyright": "pyright ./pyee ./tests"
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/jfhbrook/pyee.git"
},
"author": "Josh Holbrook",
"license": "MIT",
"bugs": {
"url": "https://github.com/jfhbrook/pyee/issues"
},
"homepage": "https://github.com/jfhbrook/pyee#readme",
"devDependencies": {
"pyright": "^1.1.159"
}
}
69 changes: 63 additions & 6 deletions pyee/__init__.py
Expand Up @@ -13,7 +13,7 @@

::

In [1]: from pyee import EventEmitter
In [1]: from pyee.base import EventEmitter

In [2]: ee = EventEmitter()

Expand All @@ -31,7 +31,8 @@

from warnings import warn

from pyee._base import EventEmitter, PyeeException
from pyee.base import EventEmitter as EventEmitter
from pyee.base import PyeeException


class BaseEventEmitter(EventEmitter):
Expand All @@ -53,28 +54,84 @@ def __init__(self):
__all__ = ["BaseEventEmitter", "EventEmitter", "PyeeException"]

try:
from pyee._asyncio import AsyncIOEventEmitter # noqa
from pyee.asyncio import AsyncIOEventEmitter as _AsyncIOEventEmitter # noqa

class AsyncIOEventEmitter(_AsyncIOEventEmitter):
"""
AsyncIOEventEmitter has been moved to the pyee.asyncio module.
"""

def __init__(self, loop=None):
warn(
DeprecationWarning(
"pyee.AsyncIOEventEmitter has been moved to the pyee.asyncio "
"module."
)
)
super(AsyncIOEventEmitter, self).__init__(loop=loop)

__all__.append("AsyncIOEventEmitter")
except ImportError:
pass

try:
from pyee._twisted import TwistedEventEmitter # noqa
from pyee.twisted import TwistedEventEmitter as _TwistedEventEmitter # noqa

class TwistedEventEmitter(_TwistedEventEmitter):
"""
TwistedEventEmitter has been moved to the pyee.twisted module.
"""

def __init__(self):
warn(
DeprecationWarning(
"pyee.TwistedEventEmitter has been moved to the pyee.twisted "
"module."
)
)
super(TwistedEventEmitter, self).__init__()

__all__.append("TwistedEventEmitter")
except ImportError:
pass

try:
from pyee._executor import ExecutorEventEmitter # noqa
from pyee.executor import ExecutorEventEmitter as _ExecutorEventEmitter # noqa

class ExecutorEventEmitter(_ExecutorEventEmitter):
"""
ExecutorEventEmitter has been moved to the pyee.executor module.
"""

def __init__(self, executor=None):
warn(
DeprecationWarning(
"pyee.ExecutorEventEmitter has been moved to the pyee.executor "
"module."
)
)
super(ExecutorEventEmitter, self).__init__(executor=executor)

__all__.append("ExecutorEventEmitter")
except ImportError:
pass

try:
from pyee._trio import TrioEventEmitter # noqa
from pyee.trio import TrioEventEmitter as _TrioEventEmitter # noqa

class TrioEventEmitter(_TrioEventEmitter):
"""
TrioEventEmitter has been moved to the pyee.trio module.
"""

def __init__(self, nursery=None, manager=None):
warn(
DeprecationWarning(
"pyee.TrioEventEmitter has been moved to the pyee.trio module."
)
)

super(TrioEventEmitter, self).__init__(nursery=nursery, manager=manager)

__all__.append("TrioEventEmitter")
except (ImportError, SyntaxError):
Expand Down