Skip to content

GitHub Actions: Lint Python code only for SyntaxErrors #94

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This Action uses minimal steps to run in ~5 seconds to rapidly:
# lint Python code using ruff which provides intuitive GitHub Annotations to contributors.
# https://docs.astral.sh/ruff/

name: ci
on:
push:
# branches: [main]
pull_request:
# branches: [main]
jobs:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with:
args: check --ignore=ALL # Turn off 800+ lint rules to only look for Python SyntaxErrors.
4 changes: 3 additions & 1 deletion capitulos/code/11-pythonic-obj/private/expose.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env jython
# NOTE: Jython is still Python 2.7 in late2020

from __future__ import print_function

import Confidential

message = Confidential('top secret text')
secret_field = Confidential.getDeclaredField('secret')
secret_field.setAccessible(True) # break the lock!
print 'message.secret =', secret_field.get(message)
print('message.secret =', secret_field.get(message))
6 changes: 4 additions & 2 deletions capitulos/code/11-pythonic-obj/private/leakprivate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env jython
# NOTE: Jython is still Python 2.7 in late2020

from __future__ import print_function

from java.lang.reflect import Modifier
import Confidential

Expand All @@ -10,5 +12,5 @@
# list private fields only
if Modifier.isPrivate(field.getModifiers()):
field.setAccessible(True) # break the lock
print 'field:', field
print '\t', field.getName(), '=', field.get(message)
print('field:', field)
print('\t', field.getName(), '=', field.get(message))
3 changes: 2 additions & 1 deletion capitulos/code/11-pythonic-obj/private/no_respect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
Set this to false and Jython provides access to non-public
fields, methods, and constructors of Java objects.
"""
from __future__ import print_function

import Confidential

message = Confidential('top secret text')
for name in dir(message):
attr = getattr(message, name)
if not callable(attr): # non-methods only
print name + '\t=', attr
print(name + '\t=', attr)