Skip to content

Commit 1190bd8

Browse files
authored
tooling: Porting to poetry/ruff (#319)
1 parent abbd83c commit 1190bd8

29 files changed

Lines changed: 2607 additions & 358 deletions

.checkignore

Lines changed: 0 additions & 3 deletions
This file was deleted.

.coveragerc

Lines changed: 0 additions & 27 deletions
This file was deleted.

.flake8

Lines changed: 0 additions & 4 deletions
This file was deleted.

.pyup.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.readthedocs.yaml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@ version: 2
99
build:
1010
os: ubuntu-20.04
1111
tools:
12-
python: "3.8"
12+
python: "3.11"
13+
jobs:
14+
post_create_environment:
15+
# Install poetry
16+
# https://python-poetry.org/docs/#installing-manually
17+
- pip install poetry
18+
# Tell poetry to not use a virtual environment
19+
- poetry config virtualenvs.create false
20+
# Install dependencies with 'docs' dependency group
21+
# https://python-poetry.org/docs/managing-dependencies/#dependency-groups
22+
- poetry install --with diagrams,docs
1323

1424
# Build documentation in the docs/ directory with Sphinx
1525
sphinx:

.travis.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

CONTRIBUTING.rst

Lines changed: 44 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -57,68 +57,72 @@ If you are proposing a feature:
5757
Get Started!
5858
------------
5959

60-
Ready to contribute? Here's how to set up `python-statemachine` for local development.
60+
Ready to contribute? Here's how to set up ``python-statemachine`` for local development.
6161

62-
1. Fork the `python-statemachine` repo on GitHub.
63-
2. Clone your fork locally::
6462

65-
$ git clone git@github.com:your_name_here/python-statemachine.git
63+
1. Fork the ``python-statemachine`` repository on GitHub.
6664

67-
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
65+
2. Clone the forked repository to your local machine by running::
6866

69-
$ mkvirtualenv python-statemachine
70-
$ cd python-statemachine/
71-
$ python setup.py develop
67+
git clone https://github.com/YOUR-USERNAME/python-statemachine.git.
7268

73-
4. Create a branch for local development::
7469

75-
$ git checkout -b name-of-your-bugfix-or-feature
70+
3. Run ``poetry install`` to install all the dependencies and create a virtual environment::
7671

77-
Now you can make your changes locally.
72+
poetry install
7873

79-
5. When you're done making changes, check that your changes pass flake8 and the tests, including
80-
testing other Python versions with tox::
74+
4. Install the pre-commit validations::
8175

82-
$ flake8 statemachine tests
83-
$ py.test
84-
$ tox
76+
pre-commit install
8577

86-
To get flake8 and tox, just pip install them into your virtualenv.
78+
5. Create a branch for local development::
8779

88-
6. To build the documentation locally, run::
80+
git checkout -b name-of-your-bugfix-or-feature
8981

90-
$ sphinx-build docs docs/_build/html
82+
6. Make changes to the code.
83+
7. Run tests to ensure they pass by running::
9184

92-
Now you can serve the local documentation using a webserver, like the built-in included
93-
with python::
85+
poetry run pytest
9486

95-
$ python -m http.server --directory docs/_build/html
87+
8. Update the documentation as needed.
9688

97-
And access your browser at http://localhost:8000/
89+
Build the documentation::
9890

99-
If you're specially writting documentation, I strongly recommend using ``sphinx-autobuild``
100-
as it improves the workflow watching for file changes and with live reloading::
91+
poetry run sphinx-build docs docs/_build/html
10192

102-
$ sphinx-autobuild docs docs/_build/html --re-ignore "auto_examples/.*"
10393

104-
Sometimes you need a full fresh of the files being build for docs, you can use::
94+
Now you can serve the local documentation using a webserver, like the built-in included
95+
with python::
10596

106-
$ rm -rf docs/_build/ docs/auto_examples
97+
python -m http.server --directory docs/_build/html
10798

108-
.. note::
99+
And access your browser at http://localhost:8000/
100+
101+
If you're specially writting documentation, I strongly recommend using ``sphinx-autobuild``
102+
as it improves the workflow watching for file changes and with live reloading::
103+
104+
poetry run sphinx-autobuild docs docs/_build/html --re-ignore "auto_examples/.*"
109105

110-
In order to get the tox working for all versions, I usually run pyenv enabling shell for
111-
those versions::
106+
Sometimes you need a full fresh of the files being build for docs, you can safelly remove
107+
all automatically generated files to get a clean state by running::
112108

113-
$ pyenv shell 3.8.1/envs/python-statemachine 3.7.6 3.6.10 3.5.9 2.7.17
109+
rm -rf docs/_build/ docs/auto_examples
114110

115-
1. Commit your changes and push your branch to GitHub::
111+
9. Commit your changes and push them to your forked repository::
116112

117-
$ git add .
118-
$ git commit -m "Your detailed description of your changes."
119-
$ git push origin name-of-your-bugfix-or-feature
113+
git add -A .
114+
git commit -m "Your detailed description of your changes."
115+
git push origin name-of-your-bugfix-or-feature
116+
117+
10. Create a pull request on the original repository for your changes to be reviewed and potentially
118+
merged. Be sure to follow the project's code of conduct and contributing guidelines.
119+
120+
121+
.. note::
122+
123+
In order to get the tox working for all versions, I usually use pyenv enabling shell for
124+
those versions.
120125

121-
2. Submit a pull request through the GitHub website.
122126

123127
Pull Request Guidelines
124128
-----------------------
@@ -128,14 +132,6 @@ Before you submit a pull request, check that it meets these guidelines:
128132
1. The pull request should include tests.
129133
2. If the pull request adds functionality, the docs should be updated. Put
130134
your new functionality into a function with a docstring, and add the
131-
feature to the list in README.rst.
132-
3. The pull request should work for Python 2.7, 3.3, 3.4 and 3.5. Check
133-
https://travis-ci.org/fgmacedo/python-statemachine/pull_requests
134-
and make sure that the tests pass for all supported Python versions.
135-
136-
Tips
137-
----
138-
139-
To run a subset of tests::
140-
141-
$ py.test tests.test_statemachine
135+
feature to the list in the next release notes.
136+
3. Consider adding yourself on the contributors list.
137+
4. The pull request should work for all supported Python versions.

Makefile

Lines changed: 0 additions & 88 deletions
This file was deleted.

docs/_static/custom_machine.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ div.sphx-glr-download a {
3535
background-image: none;
3636
border-radius: 4px;
3737
border: none;
38-
color: #404040 !important;
3938
display: inline-block;
4039
font-weight: bold;
4140
padding: 1ex;

docs/auto_examples/all_actions_machine.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"import mock\n\nfrom statemachine import State\nfrom statemachine import StateMachine\n\n\nclass AllActionsMachine(StateMachine):\n\n initial = State(\"Initial\", initial=True)\n final = State(\"Final\", final=True)\n\n go = initial.to(\n final,\n validators=[\"validation_1\", \"validation_2\"],\n cond=[\"condition_1\", \"condition_2\"],\n unless=[\"unless_1\", \"unless_2\"],\n on=[\"on_inline_1\", \"on_inline_2\"],\n before=[\"before_go_inline_1\", \"before_go_inline_2\"],\n after=[\"after_go_inline_1\", \"after_go_inline_2\"],\n )\n\n def __init__(self, *args, **kwargs):\n self.spy = mock.Mock(side_effect=lambda x: x)\n super(AllActionsMachine, self).__init__(*args, **kwargs)\n\n # validators and guards\n\n def validation_1(self):\n # this method may raise an exception\n return self.spy(\"validation_1\")\n\n def validation_2(self):\n # this method may raise an exception\n return self.spy(\"validation_2\")\n\n def condition_1(self):\n self.spy(\"condition_1\")\n return True\n\n def condition_2(self):\n self.spy(\"condition_2\")\n return True\n\n def unless_1(self):\n self.spy(\"unless_1\")\n return False\n\n def unless_2(self):\n self.spy(\"unless_2\")\n return False\n\n # generics state\n\n def on_enter_state(self):\n return self.spy(\"on_enter_state\")\n\n def on_exit_state(self):\n return self.spy(\"on_exit_state\")\n\n # generics transition\n\n def before_transition(self):\n return self.spy(\"before_transition\")\n\n def on_transition(self):\n return self.spy(\"on_transition\")\n\n def after_transition(self):\n return self.spy(\"after_transition\")\n\n # before / after specific\n\n @go.before\n def before_go_decor(self):\n return self.spy(\"before_go_decor\")\n\n def before_go_inline_1(self):\n return self.spy(\"before_go_inline_1\")\n\n def before_go_inline_2(self):\n return self.spy(\"before_go_inline_2\")\n\n def before_go(self):\n return self.spy(\"before_go\")\n\n @go.on\n def go_on_decor(self):\n return self.spy(\"go_on_decor\")\n\n def on_inline_1(self):\n return self.spy(\"on_inline_1\")\n\n def on_inline_2(self):\n return self.spy(\"on_inline_2\")\n\n def on_go(self):\n return self.spy(\"on_go\")\n\n @go.after\n def after_go_decor(self):\n return self.spy(\"after_go_decor\")\n\n def after_go_inline_1(self):\n return self.spy(\"after_go_inline_1\")\n\n def after_go_inline_2(self):\n return self.spy(\"after_go_inline_2\")\n\n def after_go(self):\n return self.spy(\"after_go\")\n\n # enter / exit specific\n\n @initial.enter\n def enter_initial_decor(self):\n return self.spy(\"enter_initial_decor\")\n\n def on_enter_initial(self):\n return self.spy(\"on_enter_initial\")\n\n @initial.exit\n def exit_initial_decor(self):\n return self.spy(\"exit_initial_decor\")\n\n def on_exit_initial(self):\n return self.spy(\"on_exit_initial\")\n\n def on_enter_final(self):\n return self.spy(\"on_enter_final\")\n\n def on_exit_final(self):\n \"hopefully this will not be called\"\n return self.spy(\"on_exit_final\")"
29+
"from unittest import mock\n\nfrom statemachine import State\nfrom statemachine import StateMachine\n\n\nclass AllActionsMachine(StateMachine):\n\n initial = State(\"Initial\", initial=True)\n final = State(\"Final\", final=True)\n\n go = initial.to(\n final,\n validators=[\"validation_1\", \"validation_2\"],\n cond=[\"condition_1\", \"condition_2\"],\n unless=[\"unless_1\", \"unless_2\"],\n on=[\"on_inline_1\", \"on_inline_2\"],\n before=[\"before_go_inline_1\", \"before_go_inline_2\"],\n after=[\"after_go_inline_1\", \"after_go_inline_2\"],\n )\n\n def __init__(self, *args, **kwargs):\n self.spy = mock.Mock(side_effect=lambda x: x)\n super(AllActionsMachine, self).__init__(*args, **kwargs)\n\n # validators and guards\n\n def validation_1(self):\n # this method may raise an exception\n return self.spy(\"validation_1\")\n\n def validation_2(self):\n # this method may raise an exception\n return self.spy(\"validation_2\")\n\n def condition_1(self):\n self.spy(\"condition_1\")\n return True\n\n def condition_2(self):\n self.spy(\"condition_2\")\n return True\n\n def unless_1(self):\n self.spy(\"unless_1\")\n return False\n\n def unless_2(self):\n self.spy(\"unless_2\")\n return False\n\n # generics state\n\n def on_enter_state(self):\n return self.spy(\"on_enter_state\")\n\n def on_exit_state(self):\n return self.spy(\"on_exit_state\")\n\n # generics transition\n\n def before_transition(self):\n return self.spy(\"before_transition\")\n\n def on_transition(self):\n return self.spy(\"on_transition\")\n\n def after_transition(self):\n return self.spy(\"after_transition\")\n\n # before / after specific\n\n @go.before\n def before_go_decor(self):\n return self.spy(\"before_go_decor\")\n\n def before_go_inline_1(self):\n return self.spy(\"before_go_inline_1\")\n\n def before_go_inline_2(self):\n return self.spy(\"before_go_inline_2\")\n\n def before_go(self):\n return self.spy(\"before_go\")\n\n @go.on\n def go_on_decor(self):\n return self.spy(\"go_on_decor\")\n\n def on_inline_1(self):\n return self.spy(\"on_inline_1\")\n\n def on_inline_2(self):\n return self.spy(\"on_inline_2\")\n\n def on_go(self):\n return self.spy(\"on_go\")\n\n @go.after\n def after_go_decor(self):\n return self.spy(\"after_go_decor\")\n\n def after_go_inline_1(self):\n return self.spy(\"after_go_inline_1\")\n\n def after_go_inline_2(self):\n return self.spy(\"after_go_inline_2\")\n\n def after_go(self):\n return self.spy(\"after_go\")\n\n # enter / exit specific\n\n @initial.enter\n def enter_initial_decor(self):\n return self.spy(\"enter_initial_decor\")\n\n def on_enter_initial(self):\n return self.spy(\"on_enter_initial\")\n\n @initial.exit\n def exit_initial_decor(self):\n return self.spy(\"exit_initial_decor\")\n\n def on_exit_initial(self):\n return self.spy(\"on_exit_initial\")\n\n def on_enter_final(self):\n return self.spy(\"on_enter_final\")\n\n def on_exit_final(self):\n \"hopefully this will not be called\"\n return self.spy(\"on_exit_final\")"
3030
]
3131
},
3232
{

0 commit comments

Comments
 (0)