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

Ruff skeleton #95

Merged
merged 12 commits into from
Sep 13, 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
8 changes: 4 additions & 4 deletions .github/CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ filing a new one. If you have a great idea but it involves big changes, please
file a ticket before making a pull request! We want to make sure you don't spend
your time coding something that might not fit the scope of the project.

.. _GitHub: https://github.com/DiamondLightSource/python3-pip-skeleton/issues
.. _GitHub: https://github.com/epics-containers/ibek/issues

Issue or Discussion?
--------------------
Expand All @@ -16,13 +16,13 @@ Github also offers discussions_ as a place to ask questions and share ideas. If
your issue is open ended and it is not obvious when it can be "closed", please
raise it as a discussion instead.

.. _discussions: https://github.com/DiamondLightSource/python3-pip-skeleton/discussions
.. _discussions: https://github.com/epics-containers/ibek/discussions

Code coverage
-------------

While 100% code coverage does not make a library bug-free, it significantly
reduces the number of easily caught bugs! Please make sure coverage remains the
reduces the number of easily caught bugs! Please make sure coverage rechange_linter_to_ruffs the
same or is improved by a pull request!

Developer guide
Expand All @@ -32,4 +32,4 @@ The `Developer Guide`_ contains information on setting up a development
environment, running the tests and what standards the code and documentation
should follow.

.. _Developer Guide: https://diamondlightsource.github.io/python3-pip-skeleton/main/developer/how-to/contribute.html
.. _Developer Guide: https://diamondlightsource.github.io/ibek/change_linter_to_ruff/developer/how-to/contribute.html
2 changes: 1 addition & 1 deletion .github/actions/install_requirements/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ runs:
mkdir -p lockfiles
pip freeze --exclude-editable > lockfiles/${{ inputs.requirements_file }}
# delete the self referencing line and make sure it isn't blank
sed -i '/file:/d' lockfiles/${{ inputs.requirements_file }}
sed -i'' -e '/file:/d' lockfiles/${{ inputs.requirements_file }}
shell: bash

- name: Upload lockfiles
Expand Down
2 changes: 1 addition & 1 deletion .github/pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
<link rel="canonical" href="main/index.html">
</head>

</html>
</html>
12 changes: 6 additions & 6 deletions .github/pages/make_switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def get_versions(ref: str, add: Optional[str], remove: Optional[str]) -> List[st
# Get a sorted list of tags
tags = get_sorted_tags_list()

# Make the sorted versions list from main branches and tags
# Make the sorted versions list from change_linter_to_ruff branches and tags
versions: List[str] = []
for version in ["master", "main"] + tags:
for version in ["master", "change_linter_to_ruff"] + tags:
if version in builds:
versions.append(version)
builds.remove(version)
Expand All @@ -64,10 +64,10 @@ def write_json(path: Path, repository: str, versions: str):
]
text = json.dumps(struct, indent=2)
print(f"JSON switcher:\n{text}")
path.write_text(text)
path.write_text(text, encoding="utf-8")


def main(args=None):
def change_linter_to_ruff(args=None):
parser = ArgumentParser(
description="Make a versions.txt file from gh-pages directories"
)
Expand Down Expand Up @@ -95,5 +95,5 @@ def main(args=None):
write_json(args.output, args.repository, versions)


if __name__ == "__main__":
main()
if __name__ == "__change_linter_to_ruff__":
change_linter_to_ruff()
7 changes: 1 addition & 6 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
run: pipdeptree

- name: Run tests
run: pytest
run: tox -e pytest

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down Expand Up @@ -183,12 +183,7 @@ jobs:
- name: Push cached image to container registry
if: github.ref_type == 'tag' # || github.ref_name == 'main'
uses: docker/build-push-action@v3
# This does not build the image again, it will find the image in the
# Docker cache and publish it
with:
# Note build-args, context, file, and target must all match between this
# step and the previous build-push-action, otherwise this step will
# attempt to build the image again
build-args: |
PIP_OPTIONS=-r lockfiles/requirements.txt dist/*.whl
context: artifacts/
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linkcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
run: tox -e docs build -- -b linkcheck

- name: Keepalive Workflow
uses: gautamkrishnar/keepalive-workflow@v1
uses: gautamkrishnar/keepalive-workflow@v1
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ venv*
# further build artifacts
lockfiles/

# tests testing folder
tests/samples/yaml/config
# ruff cache
.ruff_cache/
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ repos:
entry: black --check --diff
types: [python]

- id: flake8
name: Run flake8
- id: ruff
name: Run ruff
stages: [commit]
language: system
entry: flake8
entry: ruff
types: [python]
5 changes: 3 additions & 2 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"ms-python.python",
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"ryanluker.vscode-coverage-gutters"
"ryanluker.vscode-coverage-gutters",
"charliermarsh.Ruff"
]
}
}
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
},
}
]
}
}
17 changes: 12 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
{
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.flake8Enabled": false,
"python.linting.mypyEnabled": true,
"python.linting.enabled": true,
"python.testing.pytestArgs": [],
"python.testing.pytestArgs": [
"--cov=python3_pip_skeleton",
"--cov-report",
"xml:cov.xml"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.formatting.provider": "black",
"python.languageServer": "Pylance",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
"[python]": {
"editor.codeActionsOnSave": {
"source.fixAll.ruff": false,
"source.organizeImports.ruff": true
}
}
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
"problemMatcher": [],
}
]
}
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
of this License, Derivative Works shall not include works that rechange_linter_to_ruff
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.

Expand Down
20 changes: 7 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ibek
====
===========================

|code_ci| |docs_ci| |coverage| |pypi_version| |license|

Expand Down Expand Up @@ -27,31 +27,25 @@ TODO

This project is approaching completion. The following items are still to do:

- Complete documentation in general
from ibek import __version__

- Add a diagram and more details. Use draw.io for image, and save as SVG
with source embed in it, save as something.draw.io.svg
print(f"Hello ibek {__version__}")

- DONE: Add ability to define embedded objects e.g. AsynIp and AsynSerial would
both be defined by embedding AsynPort (so similar to how original builder.py
works)

- Add support for enums where you define the possible values inline
$ python -m ibek --version

- DONE: update helm-template/config/start.sh to call 'ibek build-startup' when it
sees a st.cmd.yaml file in the startup directory. This change requires
embedding ibek into the epics-base container image.


.. |code_ci| image:: https://github.com/epics-containers/ibek/actions/workflows/code.yml/badge.svg?branch=main
.. |code_ci| image:: https://github.com/epics-containers/ibek/actions/workflows/code.yml/badge.svg?branch=change_linter_to_ruff
:target: https://github.com/epics-containers/ibek/actions/workflows/code.yml
:alt: Code CI

.. |docs_ci| image:: https://github.com/epics-containers/ibek/actions/workflows/docs.yml/badge.svg?branch=main
.. |docs_ci| image:: https://github.com/epics-containers/ibek/actions/workflows/docs.yml/badge.svg?branch=change_linter_to_ruff
:target: https://github.com/epics-containers/ibek/actions/workflows/docs.yml
:alt: Docs CI

.. |coverage| image:: https://codecov.io/gh/epics-containers/ibek/branch/master/graph/badge.svg
.. |coverage| image:: https://codecov.io/gh/epics-containers/ibek/branch/change_linter_to_ruff/graph/badge.svg
:target: https://codecov.io/gh/epics-containers/ibek
:alt: Test Coverage

Expand Down
11 changes: 5 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

# A list of (type, target) tuples (by default empty) that should be ignored when
# generating warnings in "nitpicky mode". Note that type should include the
# domain name if present. Example entries would be ('py:func', 'int') or
# dochange_linter_to_ruff name if present. Example entries would be ('py:func', 'int') or
# ('envvar', 'LD_LIBRARY_PATH').
nitpick_ignore = [
("py:class", "NoneType"),
Expand All @@ -63,10 +63,11 @@
("py:class", "'object'"),
("py:class", "'id'"),
("py:class", "typing_extensions.Literal"),
("py:class", "type"),
]

# Dont use the __init__ docstring because pydantic base classes cause sphinx
# to generate a lot of warnings
# Both the class’ and the __init__ method’s docstring are concatenated and
# inserted into the change_linter_to_ruff body of the autoclass directive
autoclass_content = "class"

# Order the members by the order they appear in the source code
Expand Down Expand Up @@ -108,8 +109,7 @@
rst_epilog = """
.. _Diamond Light Source: http://www.diamond.ac.uk
.. _black: https://github.com/psf/black
.. _flake8: https://flake8.pycqa.org/en/latest/
.. _isort: https://github.com/PyCQA/isort
.. _ruff: https://beta.ruff.rs/docs/
.. _mypy: http://mypy-lang.org/
.. _pre-commit: https://pre-commit.com/
"""
Expand All @@ -130,7 +130,6 @@
html_theme = "pydata_sphinx_theme"
github_repo = project
github_user = "epics-containers"

switcher_json = f"https://{github_user}.github.io/{github_repo}/switcher.json"
switcher_exists = requests.get(switcher_json).ok
if not switcher_exists:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
2. Adopt python3-pip-skeleton for project structure
2. Adopt ibek for project structure
===================================================

Date: 2022-02-18
Expand All @@ -11,7 +11,7 @@ Accepted
Context
-------

We should use the following `pip-skeleton <https://github.com/DiamondLightSource/python3-pip-skeleton>`_.
We should use the following `pip-skeleton <https://github.com/epics-containers/ibek>`_.
The skeleton will ensure consistency in developer
environments and package management.

Expand All @@ -23,7 +23,7 @@ We have switched to using the skeleton.
Consequences
------------

This module will use a fixed set of tools as developed in python3-pip-skeleton
This module will use a fixed set of tools as developed in ibek
and can pull from this skeleton to update the packaging to the latest techniques.

As such, the developer environment may have changed, the following could be
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/how-to/build-docs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ changes in this directory too::

$ tox -e docs autobuild -- --watch src

.. _sphinx: https://www.sphinx-doc.org/
.. _sphinx: https://www.sphinx-doc.org/
14 changes: 6 additions & 8 deletions docs/developer/how-to/lint.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Run linting using pre-commit
============================

Code linting is handled by black_, flake8_ and isort_ run under pre-commit_.
Code linting is handled by black_ and ruff_ run under pre-commit_.

Running pre-commit
------------------
Expand All @@ -26,16 +26,14 @@ repository::

$ black .

Likewise with isort::
Likewise with ruff::

$ isort .
$ ruff --fix .

If you get any flake8 issues you will have to fix those manually.
Ruff may not be able to automatically fix all issues; in this case, you will have to fix those manually.

VSCode support
--------------

The ``.vscode/settings.json`` will run black and isort formatters as well as
flake8 checking on save. Issues will be highlighted in the editor window.


The ``.vscode/settings.json`` will run black formatting as well as
ruff checking on save. Issues will be highlighted in the editor window.
4 changes: 2 additions & 2 deletions docs/developer/how-to/make-release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To make a new release, please follow this checklist:
- Click ``Generate release notes``, review and edit these notes
- Choose a title and click ``Publish Release``

Note that tagging and pushing to the main branch has the same effect except that
Note that tagging and pushing to the change_linter_to_ruff branch has the same effect except that
you will not get the option to edit the release notes.

.. _release: https://github.com/DiamondLightSource/python3-pip-skeleton/releases
.. _release: https://github.com/epics-containers/ibek/releases
5 changes: 2 additions & 3 deletions docs/developer/reference/standards.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Code Standards
The code in this repository conforms to standards set by the following tools:

- black_ for code formatting
- flake8_ for style checks
- isort_ for import ordering
- ruff_ for style checks
- mypy_ for static type checking

.. seealso::
Expand Down Expand Up @@ -61,4 +60,4 @@ Docs follow the underlining convention::

.. seealso::

How-to guide `../how-to/build-docs`
How-to guide `../how-to/build-docs`
2 changes: 1 addition & 1 deletion docs/developer/tutorials/dev-install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ This will run in parallel the following checks:
- `../how-to/lint`


.. _epics-containers: https://epics-containers.github.io/main/user/tutorials/devcontainer.html
.. _epics-containers: https://epics-containers.github.io/change_linter_to_ruff/user/tutorials/devcontainer.html
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ The documentation is split into 2 sections:
:link: user/index
:link-type: doc

The User Guide contains documentation on how to install and use python3-pip-skeleton.
The User Guide contains documentation on how to install and use ibek.

.. grid-item-card:: :material-regular:`code;4em`
:link: developer/index
:link-type: doc

The Developer Guide contains documentation on how to develop and contribute changes back to python3-pip-skeleton.
The Developer Guide contains documentation on how to develop and contribute changes back to ibek.

.. toctree::
:hidden:
Expand Down
2 changes: 1 addition & 1 deletion docs/user/how-to/run-container.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ To pull the container from github container registry and run::

$ docker run ghcr.io/epics-containers/ibek:main --version

To get a released version, use a numbered release instead of ``main``.
To get a released version, use a numbered release instead of ``change_linter_to_ruff``.
Loading