Skip to content

Commit

Permalink
Merge pull request #9 from mobility-university/feature/visit_decorate…
Browse files Browse the repository at this point in the history
…d_function_body

visit body of decorated function
  • Loading branch information
lindt authored Oct 15, 2022
2 parents 1068f8a + c99acb7 commit 7ebd4df
Showing 3 changed files with 61 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "PR"
on:
pull_request:
branches:
- main
workflow_dispatch:

jobs:
Specification:
runs-on: ubuntu-latest
steps:
- name: Checkout This Repo
uses: actions/checkout@v3

- name: Execute Specification
run: bin/test_specification

Unittest:
runs-on: ubuntu-latest
steps:
- name: Checkout This Repo
uses: actions/checkout@v3

- name: Unit Test
run: ./dev ./bin/unittest

Format:
runs-on: ubuntu-latest
steps:
- name: Checkout This Repo
uses: actions/checkout@v3

- name: Format Check
run: |
set -e
check= ./bin/format
git diff --exit-code
Lint:
runs-on: ubuntu-latest
steps:
- name: Checkout This Repo
uses: actions/checkout@v3

- name: Lint Check
run: ./bin/lint
15 changes: 14 additions & 1 deletion flake8_newspaper_style.py
Original file line number Diff line number Diff line change
@@ -194,6 +194,16 @@ def run(self):
... self.counter += 1
... self.do_something()
... ''')
>>> lint('''
... def deco():
... ...
... def text():
... ...
... @deco
... def headline():
... text()
... ''')
8:4 NEW100 newspaper style: function text defined in line 4 should be moved down
"""
visitor = Visitor()
visitor.visit(self.tree)
@@ -213,7 +223,10 @@ def visit_AsyncFunctionDef(self, node):
def visit_FunctionDef(self, node):
self.scope.append(node)
self.functions.append((list(self.scope), node))
if not node.decorator_list:
if node.decorator_list:
for element in node.body:
self.generic_visit(element)
else:
self.generic_visit(node)
self.scope.pop()

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
setuptools.setup(
name="flake8-newspaper-style",
license="MIT",
version="0.4.2",
version="0.4.3",
description="Check code for newspaper style",
long_description=README,
long_description_content_type='text/markdown',

0 comments on commit 7ebd4df

Please sign in to comment.