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

Feature/SK-736 | Ruff linter #552

Merged
merged 33 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
448e3e7
revert --fix etc
viktorvaladi Mar 25, 2024
276c9e7
move setup.py configs
viktorvaladi Apr 5, 2024
60f9382
reset repo change
viktorvaladi Apr 29, 2024
7027d20
move init for pyproject
viktorvaladi Apr 30, 2024
81f41ff
include setup.py changes
viktorvaladi Apr 30, 2024
f3fd13c
remove generated
viktorvaladi Apr 30, 2024
ac87c09
Merge remote-tracking branch 'origin/master' into feature/SK-736
viktorvaladi Apr 30, 2024
0889f42
fix minor ruff errors
viktorvaladi Apr 30, 2024
28612e9
ruff fix
viktorvaladi Apr 30, 2024
0ff77e4
remove setup.py
viktorvaladi Apr 30, 2024
b6bf066
update test build path
viktorvaladi Apr 30, 2024
2a2ca70
cli path update
viktorvaladi Apr 30, 2024
b78ae9d
update cli path
viktorvaladi Apr 30, 2024
88c0d30
update cli path
viktorvaladi Apr 30, 2024
27b940e
fix cli path
viktorvaladi May 2, 2024
26c41e5
change dockerfile path
viktorvaladi May 2, 2024
769fd6a
change compose paths
viktorvaladi May 2, 2024
1169f15
update compose paths
viktorvaladi May 2, 2024
d426042
change path
viktorvaladi May 2, 2024
a3b338c
change pash
viktorvaladi May 2, 2024
106ec8d
add editable
viktorvaladi May 3, 2024
d8d0443
add virtualenv to pyproject
viktorvaladi May 3, 2024
69b6693
fix pyproject.toml
viktorvaladi May 3, 2024
6762531
change project structure
viktorvaladi May 3, 2024
7768adb
trigger CI
viktorvaladi May 3, 2024
e2d29c3
trigger CI
viktorvaladi May 3, 2024
daa0c62
merge main
viktorvaladi May 3, 2024
c379889
fix paths compose
viktorvaladi May 4, 2024
709c0a7
fix compose paths
viktorvaladi May 4, 2024
3730f77
setuptools for -e . in dockers
viktorvaladi May 6, 2024
ced7da9
revert setuptools enforce
viktorvaladi May 6, 2024
0baf159
Merge remote-tracking branch 'origin/master' into feature/SK-736
viktorvaladi May 6, 2024
a5855ad
enforce setuptools>65 in dockerfile
viktorvaladi May 6, 2024
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
23 changes: 13 additions & 10 deletions .devcontainer/devcontainer.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
"remoteUser": "default",
// "workspaceFolder": "/fedn",
// "workspaceMount": "source=/path/to/fedn,target=/fedn,type=bind,consistency=default",
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"exiasr.hadolint",
"yzhang.markdown-all-in-one",
"ms-python.isort"
],
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"ms-python.python",
"exiasr.hadolint",
"yzhang.markdown-all-in-one",
"charliermarsh.ruff"
]
}
},
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind,consistency=default",
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind,consistency=default"
],
"runArgs": [
"--net=host"
Expand All @@ -23,5 +27,4 @@
"BASE_IMG": "python:3.9"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets try python 3.11 here

}
}
}

}
25 changes: 2 additions & 23 deletions .github/workflows/code-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,9 @@ jobs:

- name: init venv
run: .devcontainer/bin/init_venv.sh
viktorvaladi marked this conversation as resolved.
Show resolved Hide resolved

- name: check Python imports
run: >
.venv/bin/isort . --check --diff
--skip .venv
--skip .mnist-keras
--skip .mnist-pytorch
--skip fedn_pb2.py
--skip fedn_pb2_grpc.py

- name: check Python formatting
run: >
.venv/bin/autopep8 --recursive --diff
--exclude .venv
--exclude .mnist-keras
--exclude .mnist-pytorch
--exclude fedn_pb2.py
--exclude fedn_pb2_grpc.py
.

- name: run Python linter
run: >
.venv/bin/flake8 .
--exclude ".venv,.mnist-keras,.mnist-pytorch,fedn_pb2.py,fedn_pb2_grpc.py"
- name: Ruff Linting
uses: chartboost/ruff-action@v1

- name: check for floating imports
run: >
Expand Down
139 changes: 139 additions & 0 deletions pyproject.toml
viktorvaladi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
lint = ["ruff>=0.0.220"] # MIT License (MIT)

[tool.ruff]
line-length = 160
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not this very high number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, its a very high number, but it's the one that was used on the earlier setup. I think we should lower it in the future

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which earlier setup? We have always used 79 (pep8)

target-version = "py39"

lint.select = [
"ANN", # flake8-annotations
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"C90", # mccabe
"D", # pydocstyle
"DTZ", # flake8-datetimez
"E", # pycodestyle
"ERA", # eradicate
"F", # Pyflakes
"I", # isort
"N", # pep8-naming
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PLC", # Pylint
"PLE", # Pylint
"PLR", # Pylint
"PLW", # Pylint
"PT", # flake8-pytest-style
"Q", # flake8-quotes
"RET", # flake8-return
"S", # flake8-bandit
"SIM", # flake8-simplify
"T20", # flake8-print
"TID", # flake8-tidy-imports
"W", # pycodestyle
]

exclude = [
".venv",
".mnist-keras",
".mnist-pytorch",
"fedn_pb2.py",
"fedn_pb2_grpc.py",
".ci",
"test*"
]

lint.ignore = [
"ANN002", # Missing type annotation for *args
"ANN003", # Missing type annotation for **kwargs
"ANN101", # Missing type annotation for self in method
"ANN102", # Missing type annotation for cls in method
"D107", # Missing docstring in __init__
"D100", # Missing docstring in public module
"D200", # One-line docstring should fit on one line with quotes
"D210", # [*] No whitespaces allowed surrounding docstring text (100+)
"D104", # Missing docstring in public package (17)
"ANN201", # Missing return type annotation for public function (100+)
"ANN001", # Missing type annotation for function argument (100+)
"RET504", # Unnecessary assignment to `settings` before `return` statement (72)
"ANN204", # Missing return type annotation for special method `__init__` (61)
"D205", # 1 blank line required between summary line and description (100+)
"T201", # `print` found (31)
"SIM401", # Use `result.get("id", "")` instead of an `if` block (72)
"D400", # First line should end with a period (80)
"D415", # First line should end with a period, question mark, or exclamation point (80)
"D101", # Missing docstring in public class (30)
"S113", # Probable use of requests call without timeout (41)
"PLR2004", # Magic value used in comparison, consider replacing `200` with a constant variable
"PLR0913", # Too many arguments in function definition (31)
"ANN202", # Missing return type annotation for private function (41)
"D102", # Missing docstring in public method (64)
"SIM108", # Use ternary operator instead of `if`-`else`-block (20)
"RET505", # Unnecessary `else` after `return` statement (20)
"D103", # Missing docstring in public function (17)
"D401", # First line of docstring should be in imperative mood (24)
"N818", # Exception name should be named with an Error suffix (8)
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ... from None` to distinguish them from errors in exception handling (11)
"DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed (18)
"ANN206", # Missing return type annotation for classmethod (1)
"S110", # `try`-`except`-`pass` detected, consider logging the exception (3)
"N803", # Argument name should be lowercase
"N805", # First argument of a method should be named `self`
"SIM118", # Use `key in dict` instead of `key in dict.keys()`
"SIM115", # Use context handler for opening files
"B027", # `StateStoreBase.__init__` is an empty method in an abstract base class, but has no abstract decorator
"ARG002", # Unused method argument: `use_typing`
"B006", # Do not use mutable data structures for argument defaults
"PLR1714", # Consider merging multiple comparisons: `retcheck in ("", " ")`. Use a `set` if the elements are hashable.
"ERA001", # Found commented-out code
"N802", # Function name should be lowercase
"SIM116", # Use a dictionary instead of consecutive `if` statements
"RET503", # Missing explicit `return` at the end of function able to return non-`None` value
"PLR0911", # Too many return statements (11 > 6)
"C901", # function is too complex (11 > 10)
"ARG001", # Unused function argument:
"SIM105", # Use `contextlib.suppress(KeyError)` instead of `try`-`except`-`pass`
"PLR0915", # Too many statements
"B024", # `Config` is an abstract base class, but it has no abstract methods
"RET506", # Unnecessary `else` after `raise` statement
"N804", # First argument of a class method should be named `cls`
"S202", # Uses of `tarfile.extractall()`
"PLR0912", # Too many branches
"SIM211", # Use `not ...` instead of `False if ... else True`
"D404", # First word of the docstring should not be "This"
"PLW0603", # Using the global statement to update ... is discouraged
"D105", # Missing docstring in magic method
"PLR1722", # Use `sys.exit()` instead of `exit`
"C408", # Unnecessary `dict` call (rewrite as a literal)
"DTZ007", # The use of `datetime.datetime.strptime()` without %z must be followed by `.replace(tzinfo=)` or `.astimezone()`
"PLW2901", # `for` loop variable `val` overwritten by assignment target
"D419", # Docstring is empty
"C416", # Unnecessary `list` comprehension (rewrite using `list()`)
"SIM102", # Use a single `if` statement instead of nested `if` statements
"PLW1508", # Invalid type for environment variable default; expected `str` or `None`
"B007", # Loop control variable `v` not used within loop body
"N806", # Variable `X_test` in function should be lowercase

# solved with --fix
"Q000", # [*] Single quotes found but double quotes preferred
"D212", # [*] Multi-line docstring summary should start at the first line
"D213", # [*] Multi-line docstring summary should start at the second line
"D202", # [*] No blank lines allowed after function docstring (found 1)
"D209", # [*] Multi-line docstring closing quotes should be on a separate line
"D204", # [*] 1 blank line required after class docstring
"SIM114", # [*] Combine `if` branches using logical `or` operator
"D208", # [*] Docstring is over-indented
"I001", # [*] Import block is un-sorted or un-formatted
"SIM103", # Return the condition directly
"PLR5501", # [*] Use `elif` instead of `else` then `if`, to reduce indentation
"RET501", # [*] Do not explicitly `return None` in function if it is the only possible return value
"PLW0120", # [*] `else` clause on loop without a `break` statement; remove the `else` and dedent its contents

# unsafe?
"S104", # Possible binding to all interfaces

"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
"S501", # Probable use of `requests` call with `verify=False` disabling SSL certificate checks
"S108", # Probable insecure usage of temporary file or directory: "/tmp/models"
"S603", # `subprocess` call: check for execution of untrusted input
]
5 changes: 0 additions & 5 deletions setup.cfg

This file was deleted.