diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 7bdc653d2..000000000 --- a/.flake8 +++ /dev/null @@ -1,22 +0,0 @@ -[flake8] -max-line-length = 115 - -ignore = - # these rules don't play well with black - # whitespace before : - E203 - # line break before binary operator - W503 - -exclude = - .venv - .git - __pycache__ - docs/build - dist - .mypy_cache - -per-file-ignores = - # __init__.py files are allowed to have unused imports and lines-too-long - */__init__.py:F401 - */**/**/__init__.py:F401,E501 diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index f6490b2ce..a0cf88936 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -18,22 +18,22 @@ code sample or an executable test case demonstrating the expected behavior. We use GitHub issues to track feature requests. Before you create a feature request: -* Make sure you have a clear idea of the enhancement you would like. If you have a vague idea, consider discussing -it first on a GitHub issue. -* Check the documentation to make sure your feature does not already exist. -* Do [a quick search](https://github.com/allenai/tango/issues) to see whether your feature has already been suggested. +- Make sure you have a clear idea of the enhancement you would like. If you have a vague idea, consider discussing + it first on a GitHub issue. +- Check the documentation to make sure your feature does not already exist. +- Do [a quick search](https://github.com/allenai/tango/issues) to see whether your feature has already been suggested. When creating your request, please: -* Provide a clear title and description. -* Explain why the enhancement would be useful. It may be helpful to highlight the feature in other libraries. -* Include code examples to demonstrate how the enhancement would be used. +- Provide a clear title and description. +- Explain why the enhancement would be useful. It may be helpful to highlight the feature in other libraries. +- Include code examples to demonstrate how the enhancement would be used. ## Making a pull request When you're ready to contribute code to address an open issue, please follow these guidelines to help us be able to review your pull request (PR) quickly. -1. **Initial setup** (only do this once) +1. **Initial setup** (only do this once)
Expand details 👇
@@ -47,7 +47,7 @@ When you're ready to contribute code to address an open issue, please follow the git clone git@github.com:USERNAME/tango.git - At this point the local clone of your fork only knows that it came from *your* repo, github.com/USERNAME/tango.git, but doesn't know anything the *main* repo, [https://github.com/allenai/tango.git](https://github.com/allenai/tango). You can see this by running + At this point the local clone of your fork only knows that it came from _your_ repo, github.com/USERNAME/tango.git, but doesn't know anything the _main_ repo, [https://github.com/allenai/tango.git](https://github.com/allenai/tango). You can see this by running git remote -v @@ -93,7 +93,7 @@ When you're ready to contribute code to address an open issue, please follow the
-2. **Ensure your fork is up-to-date** +2. **Ensure your fork is up-to-date**
Expand details 👇
@@ -105,7 +105,7 @@ When you're ready to contribute code to address an open issue, please follow the
-3. **Create a new branch to work on your fix or enhancement** +3. **Create a new branch to work on your fix or enhancement**
Expand details 👇
@@ -119,11 +119,11 @@ When you're ready to contribute code to address an open issue, please follow the
-4. **Test your changes** +4. **Test your changes**
Expand details 👇
- Our continuous integration (CI) testing runs [a number of checks](https://github.com/allenai/tango/actions) for each pull request on [GitHub Actions](https://github.com/features/actions). You can run most of these tests locally, which is something you should do *before* opening a PR to help speed up the review process and make it easier for us. + Our continuous integration (CI) testing runs [a number of checks](https://github.com/allenai/tango/actions) for each pull request on [GitHub Actions](https://github.com/features/actions). You can run most of these tests locally, which is something you should do _before_ opening a PR to help speed up the review process and make it easier for us. First, you should run [`isort`](https://github.com/PyCQA/isort) and [`black`](https://github.com/psf/black) to make sure you code is formatted consistently. Many IDEs support code formatters as plugins, so you may be able to setup isort and black to run automatically everytime you save. @@ -133,9 +133,9 @@ When you're ready to contribute code to address an open issue, please follow the isort . black . - Our CI also uses [`flake8`](https://github.com/allenai/tango/tree/main/tests) to lint the code base and [`mypy`](http://mypy-lang.org/) for type-checking. You should run both of these next with + Our CI also uses [`ruff`](https://github.com/charliermarsh/ruff) to lint the code base and [`mypy`](http://mypy-lang.org/) for type-checking. You should run both of these next with - flake8 . + ruff check . and @@ -177,19 +177,20 @@ in addition to everything listed in [Making a pull request](#making-a-pull-reque 1. First start by creating a new submodule `tango.integrations.name_of_integration` and put all of the code for your integration in there. 2. Then you must add a module docstring to the `__init__.py` file of the submodule which imports all of the public components of the integration, - and defines the [`__all__`](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package) special variable to include all of those components. - This ensures all of the public components will show up in the documentation. + and defines the [`__all__`](https://docs.python.org/3/tutorial/modules.html#importing-from-a-package) special variable to include all of those components. + This ensures all of the public components will show up in the documentation. 3. Next that you should add unit tests of your code to `tests/integrations/name_of_integration/`. 4. Then add a new file `docs/source/api/integrations/name_of_integration.rst`, and include the directive: - ``` - .. automodule:: tango.integrations.name_of_integration - :members: - ``` + ``` + .. automodule:: tango.integrations.name_of_integration + :members: + ``` + + Take a look at any of the other files in that folder to see how it should look exactly. - Take a look at any of the other files in that folder to see how it should look exactly. 5. And then add `name_of_integration` to the `toctree` in `docs/source/api/integrations/index.rst`. 6. After that, add any additional requirements that your integration depends on to `requirements.txt`. Be sure to put those under the "Extra dependencies for integrations" section, - and add the special inline comment `# needed by: name_of_integration`. + and add the special inline comment `# needed by: name_of_integration`. 7. And finally, in the `checks` job definition in `.github/workflows/main.yml`, add a new object - to the matrix for your integration following the other examples there. + to the matrix for your integration following the other examples there. diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9174a0021..2a327176f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,7 +41,7 @@ jobs: extras: dev,all requires_torch: true run: | - flake8 . + ruff check . - name: Type check extras: dev,all diff --git a/Makefile b/Makefile index 47d226818..b010d4ca9 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ docs : run-checks : isort --check . black --check . - flake8 . + ruff check . mypy --check-untyped-defs . CUDA_VISIBLE_DEVICES='' pytest -v --color=yes --doctest-modules --ignore=tests/integrations --ignore=tango/integrations tests/ tango/ CUDA_VISIBLE_DEVICES='' pytest -v --color=yes --doctest-modules tango/integrations/torch tests/integrations/torch diff --git a/pyproject.toml b/pyproject.toml index 748795065..6f7a64c2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -41,7 +41,7 @@ dependencies = [ [project.optional-dependencies] dev = [ - "flake8", + "ruff", "mypy==1.2.0", "types-PyYAML", "types-setuptools", @@ -156,6 +156,22 @@ exclude = ''' profile = "black" multi_line_output = 3 +[tool.ruff] +line-length = 115 +select = ["E"] +exclude = [ + ".venv", + ".git", + "__pycache__", + ".mypy_cache", + "docs/build", + "dist" +] + +[tool.ruff.per-file-ignores] +"__init__.py" = ["F401"] +"*/**/**/__init__.py" = ["F401","E501"] + [tool.mypy] ignore_missing_imports = true no_site_packages = false