Skip to content

Commit

Permalink
Use ruff formatter and linter (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
muffinmad authored Nov 17, 2023
1 parent e0c7600 commit e6dd190
Show file tree
Hide file tree
Showing 11 changed files with 371 additions and 268 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ jobs:
run: |
python -m pip install --upgrade pip
make install
- name: Lint with pycodestyle and pyflakes
- name: Check code with linter and formatter
run: |
make flake
- name: Test with pytest
make check
- name: Run tests
run: |
make test
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
# sort imports
- id: ruff
args: [--select, I, --fix]
# format
- id: ruff-format
2 changes: 0 additions & 2 deletions .pycodestylerc

This file was deleted.

8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ install: clean
$(PYTHON) -m pip install -r requirements.txt


.PHONY: flake flake8
flake flake8:
pycodestyle --config .pycodestylerc .
pyflakes .
.PHONY: check
check:
ruff format --check .
ruff check .

.PHONY: test
test:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,10 @@ Set it in project's dir-locals file.")
```
pip install anakin-language-server
```

## Development

```
pip install pre-commit
pre-commit install
```
26 changes: 7 additions & 19 deletions anakinls/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import logging

from .server import server
from .version import __version__
from .version import __copyright__, __version__

logging.basicConfig(level=logging.INFO)
logging.getLogger('pygls.protocol').setLevel(logging.WARN)
Expand All @@ -29,39 +29,27 @@ def main():
parser.description = 'Yet another Jedi Python language server'

parser.add_argument(
'--tcp', action='store_true',
help='Use TCP server instead of stdio'
'--tcp', action='store_true', help='Use TCP server instead of stdio'
)

parser.add_argument(
'--host', default='127.0.0.1',
help='Bind to this address'
'--host', default='127.0.0.1', help='Bind to this address'
)

parser.add_argument(
'--port', type=int, default=2087,
help='Bind to this port'
'--port', type=int, default=2087, help='Bind to this port'
)

parser.add_argument(
'--version', action='store_true',
help='Print version and exit'
'--version', action='store_true', help='Print version and exit'
)

parser.add_argument(
'-v', action='store_true',
help='Verbose output'
)
parser.add_argument('-v', action='store_true', help='Verbose output')

args = parser.parse_args()

if args.version:
print(inspect.cleandoc(f'''anakinls v{__version__}
Copyright (C) 2020 Andrii Kolomoiets
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
'''))
print(inspect.cleandoc(f'anakinls v{__version__}{__copyright__}'))
return

if args.v:
Expand Down
Loading

0 comments on commit e6dd190

Please sign in to comment.