Repository navigation
Adopt Ruff, add Snyk scan and remove Codacy #243
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
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
56ceff6
Add Ruff configuration replacing flake8
jguz-pubnub 5071154
Run Ruff lint and format checks in CI on every PR
jguz-pubnub b2ea061
Remove Codacy configuration
jguz-pubnub 2a7f4b2
Unify Validations workflow triggers and concurrency
jguz-pubnub 52ff2c3
Run Validations on push only
jguz-pubnub ac08d04
Drop unused pull_request reference from format check
jguz-pubnub 3c37fd9
Lint only in CI; drop ruff format check
jguz-pubnub a9b121e
Move ruff format note from workflow to PR comment
jguz-pubnub 8091d09
Remove header comment from ruff.toml
jguz-pubnub 24987c3
Add Ruff preview rules for flake8 parity, exclude tests, pin Ruff, ad…
jguz-pubnub afffae8
Update DEVELOPER.md for Ruff setup and vulnerability scan
jguz-pubnub 4eb6a5d
Enable Ruff security rules (S) to replace Codacy Bandit checks
jguz-pubnub 1d82d71
ruff.toml
jguz-pubnub 3bdf538
DEVELOPER.md + ruff.toml
jguz-pubnub c569a81
Add Ruff B, PL, SIM and C90 rules and lint tests with E, F, W
jguz-pubnub de33cd3
ruff.toml
jguz-pubnub d28911c
Merge branch 'master' into python-ruff
jguz-pubnub c4c175e
Merge branch 'master' into python-ruff
jguz-pubnub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| name: Vulnerability scan | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| - main | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| security: | ||
| name: Snyk dependency scan | ||
| runs-on: | ||
| group: organization/Default | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Python 3.11 | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: "3.11" | ||
| - name: Install SDK dependencies | ||
| run: pip3 install --user . | ||
| - name: Setup Snyk CLI | ||
| uses: snyk/actions/setup@master | ||
| - name: Run Snyk monitor for vulnerabilities | ||
| run: snyk monitor --org=sdk --file=setup.py | ||
| env: | ||
| SNYK_TOKEN: ${{ secrets.SNYK_SDK_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| line-length = 120 | ||
| extend-exclude = ["scripts", "src", ".cache", ".idea", ".tox", "venv"] | ||
|
|
||
| [lint] | ||
| preview = true | ||
| select = ["E", "F", "W", "S", "B", "PL", "SIM", "C90"] | ||
| ignore = [ | ||
| "E402", # module-level import not at top | ||
| "F811", # redefinition of unused name | ||
| "S101", # assert | ||
| "PLR0904", # too many public methods | ||
| "PLR0911", # too many return statements | ||
| "PLR0912", # too many branches | ||
| "PLR0913", # too many arguments | ||
| "PLR0914", # too many local variables | ||
| "PLR0915", # too many statements | ||
| "PLR0916", # too many boolean expressions | ||
| "PLR0917", # too many positional arguments | ||
| "PLR2004", # magic value in comparison | ||
| "PLR6301", # method could be a function (no self use) | ||
| "PLW0717", # too many statements in try clause | ||
| "B006", # mutable argument default | ||
| "B018", # useless expression | ||
| "B028", # warnings.warn without explicit stacklevel | ||
| "B903", # class that could be a dataclass/namedtuple | ||
| "B904", # raise inside except without `from` | ||
| "B909", # mutating a collection while iterating over it | ||
| "SIM102", # nested ifs that can be collapsed | ||
| "SIM105", # try/except/pass that can use contextlib.suppress | ||
| "SIM108", # if/else block that can be a ternary | ||
| "SIM113", # manual loop counter instead of enumerate | ||
| "SIM114", # if branches with identical bodies | ||
| "SIM115", # open() without a context manager | ||
| "SIM118", # `key in dict.keys()` | ||
| "SIM211", # `False if x else True` instead of `not x` | ||
| "SIM300", # Yoda condition | ||
| "SIM401", # if/else that can be dict.get | ||
| "PLC0414", # useless import alias | ||
| "PLC0415", # import outside top level | ||
| "PLC1901", # comparison to empty string | ||
| "PLE0307", # __str__ returning non-str | ||
| "PLR1722", # exit() instead of sys.exit() | ||
| "PLR5501", # else + if that can be elif | ||
| "PLR6201", # list/tuple literal in membership test (use set) | ||
| "PLW0108", # unnecessary lambda | ||
| "PLW0127", # self-assigning variable | ||
| "PLW0128", # redeclared assigned name | ||
| "PLW1508", # non-string default for os.getenv | ||
| "PLW1514", # open() without explicit encoding | ||
| ] | ||
|
|
||
| [lint.mccabe] | ||
| max-complexity = 25 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, the highest value is 25. This should be lowered over time as an SDK is refactored or improved. |
||
|
|
||
| [lint.per-file-ignores] | ||
| "tests/**" = ["S", "B", "PL", "SIM", "C90"] | ||
| "examples/**" = ["S104", "S108", "S110"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,2 @@ | ||
| [tool:pytest] | ||
| norecursedirs = benchmarks | ||
|
|
||
| [flake8] | ||
| max-line-length = 120 | ||
| ignore=E402 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| import logging | ||
| import unittest | ||
| import urllib | ||
| import urllib.parse | ||
|
|
||
| import pubnub | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ruff replaces
flake8(and Codacy) for linting; the rules mirror the previousflake8setup. Also, ruff format is intentionally not enforced because the legacy codebase is not ruff-formatted. The estimated scope is ~280 of ~360 files, ~17k changed lines. Therefore, formatting it here would bury functional changes and break git blame. This should be done in a separate, formatting-only PR.