Skip to content

Commit

Permalink
Modernize code to pass linter checks (#445)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Vidya Ramakrishnan <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anish TP <[email protected]>
Co-authored-by: Mitesh Ashar <[email protected]>
  • Loading branch information
5 people authored Mar 5, 2024
1 parent 6ae1071 commit 8dc4c1e
Show file tree
Hide file tree
Showing 197 changed files with 14,627 additions and 17,407 deletions.
16 changes: 16 additions & 0 deletions .deepsource.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version = 1
test_patterns = [
"tests/**"
]
exclude_patterns = [
"**/node_modules/",
"migrations/**/*"
]

[[analyzers]]
name = "python"
enabled = true
runtime_version = "3.x.x"

[analyzers.meta]
max_line_length = 88
21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const OFF = 0;
const WARN = 1;
const ERROR = 2;
module.exports = {
parser: 'babel-eslint',
env: {
browser: true,
es6: true,
jquery: true,
},
extends: ['airbnb-base', 'plugin:prettier/recommended'],
rules: {
'no-console': WARN,
'prefer-arrow-callback': [ERROR, { allowNamedFunctions: true }],
'prefer-const': WARN,
'new-cap': WARN,
'no-param-reassign': [ERROR, { props: false }],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? ERROR : OFF,
},
};
143 changes: 143 additions & 0 deletions .github/workflows/telegram.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
name: Telegram Notify
on:
issues:
types: [opened, edited, closed, reopened, milestoned, demilestoned]
issue_comment:
types: [created]
push:
pull_request:
types:
# Exclude 'synchronize' as that is duplicated in the 'push' event
[
assigned,
closed,
converted_to_draft,
edited,
labeled,
locked,
opened,
ready_for_review,
reopened,
review_request_removed,
review_requested,
unassigned,
unlabeled,
unlocked,
]
pull_request_review:
project:
project_card:
types: [created, moved, converted, edited, deleted]
release:
watch:

jobs:
tguser:
runs-on: ubuntu-latest
steps:
- uses: kanga333/variable-mapper@master
with:
key: '${{ github.actor }}'
map: |
{
"djamg": {"tguser": "@dj_amg"},
"jace": {"tguser": "@jackerhack"},
"miteshashar": {"tguser": "@miteshashar"},
"sankarshanmukhopadhyay": {"tguser": "@sankarshan"},
"StephanieBr": {"tguser": "@stephaniebrne"},
"vidya-ram": {"tguser": "@vidya_ramki"},
"zainabbawa": {"tguser": "@Saaweoh"},
"anishTP": {"tguser": "@anishtp"},
".*": {"tguser": "Unknown"}
}
export_to: env
outputs:
tguser: ${{ env.tguser }}

event_notify_all:
if: ${{ !contains(fromJson('["issues", "issue_comment", "pull_request", "pull_request_review", "push"]'), github.event_name) }}
needs: tguser
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message: |
<b>${{ github.event_name }}</b> by ${{ needs.tguser.outputs.tguser }} (${{ github.actor }}) in https://github.com/${{ github.repository }}
event_issues:
if: ${{ github.event_name == 'issues' }}
needs: tguser
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message: |
<b>${{ github.event_name }}/${{ github.event.action }}</b> by ${{ needs.tguser.outputs.tguser }} (${{ github.actor }}): ${{ github.event.issue.title }} ${{ github.event.issue.html_url }}
event_issue_comment:
if: ${{ github.event_name == 'issue_comment' }}
needs: tguser
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message: |
<b>${{ github.event_name }}/${{ github.event.action }}</b> by ${{ needs.tguser.outputs.tguser }} (${{ github.actor }}) in ${{ github.event.issue.title }} ${{ github.event.issue.html_url }}:
${{ github.event.comment.body }} ${{ github.event.comment.html_url }}
event_pull_request:
if: ${{ github.event_name == 'pull_request' }}
needs: tguser
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message: |
<b>${{ github.event_name }}/${{ github.event.action }}</b> by ${{ needs.tguser.outputs.tguser }} (${{ github.actor }}): ${{ github.event.pull_request.title }} ${{ github.event.pull_request.html_url }}
event_pull_request_review:
if: ${{ github.event_name == 'pull_request_review' }}
needs: tguser
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message: |
<b>${{ github.event_name }}/${{ github.event.action }} (${{ github.event.review.state }})</b> by ${{ needs.tguser.outputs.tguser }} (${{ github.actor }}) in ${{ github.event.pull_request.title }} ${{ github.event.pull_request.html_url }}:
${{ github.event.review.body }} ${{ github.event.review.html_url }}
event_push:
if: ${{ github.event_name == 'push' }}
needs: tguser
runs-on: ubuntu-latest
steps:
- uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
format: html
disable_web_page_preview: true
message: |
<b>${{ github.event_name }}</b> by ${{ needs.tguser.outputs.tguser }} (${{ github.actor }}) in ${{ github.repository }}/${{ github.ref_name }}: ${{ github.event.head_commit.message }} ${{ github.event.compare }}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ baseframe-packed.js
baseframe-packed.css
.vscode
.coverage
.python-version
boxoffice/static/gen/*
*.sql
*.sql.gz
Expand All @@ -19,6 +20,7 @@ node_modules
boxoffice/static/build
.pytest_cache
boxoffice/static/img/fa5-packed.svg

monkeytype.sqlite3
.env
.env.testing
.envrc
71 changes: 58 additions & 13 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.3.0
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
# Extra args, only after removing flake8 and yesqa: '--extend-select', 'RUF100'
- repo: https://github.com/lucasmbrown/mirrors-autoflake
rev: v1.3
hooks:
Expand All @@ -13,6 +19,32 @@ repos:
'--remove-unused-variables',
'--remove-duplicate-keys',
]
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.1
hooks:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py311-plus']
- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa
additional_dependencies: &flake8deps
- bandit
- flake8-assertive
- flake8-blind-except
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-docstrings
- flake8-isort
- flake8-logging-format
- flake8-mutable
- flake8-plugin-utils
- flake8-print
- flake8-pytest-style
- pep8-naming
- toml
- tomli
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
Expand Down Expand Up @@ -54,31 +86,44 @@ repos:
rev: v1.8.0
hooks:
- id: mypy
# warn-unused-ignores is unsafe with pre-commit, see
# https://github.com/python/mypy/issues/2960
args: ['--no-warn-unused-ignores', '--ignore-missing-imports']
additional_dependencies:
- flask
- sqlalchemy
- types-all
- toml
- tomli
- types-python-dateutil
- types-pytz
- types-requests
- types-setuptools
- typing-extensions
- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies: *flake8deps
- repo: https://github.com/PyCQA/pylint
rev: v3.1.0
hooks:
- id: pylint
args: [
'--disable=import-error',
'-rn', # Disable full report
'-sn', # Disable evaluation score
'--ignore-paths=migrations',
]
additional_dependencies:
- toml
- flake8-assertive
- flake8-blind-except
- flake8-builtins
- flake8-comprehensions
- flake8-docstrings
- flake8-isort
- flake8-logging-format
- flake8-mutable
- flake8-print
- pep8-naming
- tomli
- repo: https://github.com/PyCQA/bandit
rev: 1.7.7
hooks:
- id: bandit
language_version: python3
exclude: (^tests|funnel/loginproviders/flask_oauth.py)
args: ['-c', 'pyproject.toml']
additional_dependencies:
- 'bandit[toml]'
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: python
python:
- 3.7
addons:
postgresql: 12
postgresql: '12'
apt:
packages:
- postgresql-12
Expand Down Expand Up @@ -32,7 +32,7 @@ before_script:
- psql -c 'create database boxoffice_testing;' -U postgres
- flask dbconfig | sudo -u postgres psql boxoffice_testing
script:
- ./runtests.sh
- pytest
after_success:
- coveralls
notifications:
Expand Down
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
all:
cd boxoffice/assets; make
all: assets

assets:
npm install
npm run build

assetsonly:
npm run build
Loading

0 comments on commit 8dc4c1e

Please sign in to comment.