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

Setup code formatting and linting #1404

Merged
merged 4 commits into from
Apr 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
architecture: 'x64'
- name: Install flake8
run: |
pip install flake8 flake8-import-order
pip install flake8 isort flake8-isort
- name: Lint python with flake8
run: |
flake8 . --max-complexity=10 --statistics
Expand Down
5 changes: 5 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[settings]
force_single_line=true

multi_line_output=7
profile=black
30 changes: 26 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ Examples:

- To update the submodule, you would still need to follow the contribution guide in the submodule repository. And then create a PR for the main repository with the updated submodule commit.


### Back end

Install Python

Install the ASReview package
Expand All @@ -37,6 +37,26 @@ For Windows, use
set FLASK_DEBUG=1
asreview lab

#### Formatting and linting

Use `flake8` to lint the Python code and format the code with `black`. Use
`black[jupyter]` if you are editing the Jupyter notebooks. Use `isort` to
sort the imports.

Install the linters and formatters with:

```sh
pip install black[jupyter] flake8 flake8-isort isort
```

Run the following commands to lint and format:

```sh
black .
isort .
flake8 .
```

### Front end

Install both [npm][1] and Python
Expand Down Expand Up @@ -64,6 +84,11 @@ Open the web browser at `localhost:3000`

**Important**: Ignore `localhost:5000`. You can also find a front end on `:5000` but this is not relevant for the current front end development step.

[1]: https://www.npmjs.com/get-npm
[2]: https://reactjs.org/

#### Formatting and linting

Please make use of Prettier (https://prettier.io/docs/en/install.html) to
format React/Javascript code. Use the following code to format all files in
the webapp folder.
Expand All @@ -73,9 +98,6 @@ cd asreview/webapp
npx prettier --write .
```

[1]: https://www.npmjs.com/get-npm
[2]: https://reactjs.org/

## Authentication

It is possible to run ASReview with authentication, enabling multiple users to run their
Expand Down
16 changes: 8 additions & 8 deletions asreview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@

from ._version import get_versions

__version__ = get_versions()['version']
__version__ = get_versions()["version"]
del get_versions

__all__ = [
'asreview_path',
'ASReviewData',
'ASReviewProject',
'get_data_home',
'list_readers',
'list_writers',
'open_state'
"asreview_path",
"ASReviewData",
"ASReviewProject",
"get_data_home",
"list_readers",
"list_writers",
"open_state",
]
8 changes: 3 additions & 5 deletions asreview/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,17 @@ def main():
entry_points = get_entry_points("asreview.entry_points")

if (
len(sys.argv) > 1 and
not sys.argv[1].startswith("-") and
sys.argv[1] not in entry_points
len(sys.argv) > 1
and not sys.argv[1].startswith("-")
and sys.argv[1] not in entry_points
):
raise ValueError(f"'{sys.argv[1]}' is not a valid subcommand.")

elif len(sys.argv) > 1 and sys.argv[1] in entry_points:

entry = entry_points[sys.argv[1]]
entry.load()().execute(sys.argv[2:])

else:

description_subcommands = ""

for name, pkg_entry_points in groupby(
Expand Down