Skip to content

Commit

Permalink
Merge branch 'omaster'
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyfadeev committed Jan 22, 2024
2 parents 0adf4e1 + bf43e80 commit 02b50a2
Show file tree
Hide file tree
Showing 5 changed files with 202 additions and 9 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,19 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
# see https://github.com/pre-commit/action/#using-this-action
- name: pre-commit checks
uses: pre-commit/[email protected]
env:
# it's okay for github to commit to main/master
SKIP: no-commit-to-branch
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools-rust
python setup.py install
# replacement for "python setup.py install"
# See also https://packaging.python.org/en/latest/discussions/setup-py-deprecated/#setup-py-deprecated
python -m pip install .
pip install -r requirements-tests.txt
cat askbot_setup_test_inputs.txt | askbot-setup
- name: Run tests
Expand Down
90 changes: 90 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# See http://pre-commit.com/#python
# See https://github.com/pre-commit/pre-commit-hooks
# Run 'pre-commit install' to install the pre-commit hooks
repos:

# TODO: enable
#- repo: https://github.com/adamchainz/django-upgrade
# rev: 1.15.0
# hooks:
# - id: django-upgrade
# args: [--target-version, "4.2"]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
# TODO: enable check-docstring-first
# - id: check-docstring-first
- id: check-merge-conflict
- id: check-symlinks
- id: debug-statements
- id: detect-private-key
# ruff format will handle quoting
# - id: double-quote-string-fixer
# TODO: enable each of these, one at a time:
# - id: end-of-file-fixer
# - id: mixed-line-ending
# - id: trailing-whitespace
# exclude: (.csv|.tsv)$
# - id: pretty-format-json
# args: ['--no-sort-keys', '--autofix']
# don't commit directly to main or master
- id: no-commit-to-branch

# TODO: enable auto-formatting of Django templates (html, css, js)
#- repo: https://github.com/rtts/djhtml
# rev: '3.0.6'
# hooks:
# - id: djhtml
# - id: djcss
# - id: djjs

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.5
hooks:
- id: ruff
args: ["--fix"]
# TODO: ruff-format
# - id: ruff-format

# ruff does not re-implement all of pylint, see https://github.com/astral-sh/ruff/issues/970
# TODO: put back pylint
#- repo: https://github.com/PyCQA/pylint
# rev: v3.0.1
# hooks:
# - id: pylint
# args:
# # black is controlling line length:
# - --disable=line-too-long
# # let's not worry too much right now about dup code.
# - --disable=duplicate-code
# - --disable=fixme
# - --disable=import-error
# - --disable=logging-fstring-interpolation
# - --disable=missing-class-docstring
# - --disable=missing-function-docstring
# - --disable=missing-module-docstring
# - --disable=too-few-public-methods
# - --disable=too-many-arguments
# # - --disable=too-many-branches
# - --disable=too-many-locals
# # isort is taking care of import order:
# - --disable=wrong-import-order
# # re-enable these args
# - --disable=unused-argument
# - --disable=invalid-name
# - --disable=raise-missing-from

#- repo: https://github.com/Lucas-C/pre-commit-hooks
# rev: v1.5.4
# hooks:
# # TODO: enable forbid-crlf and forbid-tabs
# # - id: forbid-crlf
# # don't remove-crlf, seems dangerous
# # - id: remove-crlf
# # - id: forbid-tabs
# # don't remove-tabs, seems dangerous
# # - id: remove-tabs
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@ Branch `0.7.x` - is the latest version supporting Django 1.5

## Installation

Installation was tested with Python 3.7 with the following commands:
Install as follows:

pip install --upgrade pip
pip install setuptools-rust
python setup.py install
askbot-setup # answer the questions or use parameters to askbot-setup
cd <root_dir> # substitute <root_dir> with the actual directory, default is `askbot_site`
python manage.py migrate # assumes that the database specified by askbot-setup is available
```
pip install --upgrade pip
pip install setuptools-rust
python -m pip install .
askbot-setup # answer the questions or use parameters to askbot-setup
cd <root_dir> # substitute <root_dir> with the actual directory, default is `askbot_site`
python manage.py migrate # assumes that the database specified by askbot-setup is available
```

The last command above will create a working Django project in the project root
directory that you specify with the `askbot-setup` script.
Expand All @@ -52,6 +54,19 @@ All documentation is in the directory askbot/doc
Follow https://help.github.com/articles/fork-a-repo to to learn how to use
`fetch` and `push` as well as other help on using git.

pre-commit
==========

This repository uses [pre-commit](https://pre-commit.com/) to check
some code rules, so please install it:

```
$ pre-commit install
```

It will then check the rules upon `git commit`.


License, copyright and trademarks
=================================
Askbot software is licensed under GPL, version 3.
Expand Down
2 changes: 1 addition & 1 deletion askbot/management/commands/askbot_add_osqa_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def import_users(self):
self.copy_bool_parameter(from_user, to_user, 'is_staff')
self.copy_bool_parameter(from_user, to_user, 'is_active')
self.copy_bool_parameter(from_user, to_user, 'is_superuser')
if from.user.is_superuser:
if from_user.is_superuser:
to_user.set_status('d')
self.copy_numeric_parameter(from_user, to_user, 'last_login', operator='max')
self.copy_numeric_parameter(from_user, to_user, 'date_joined', operator='min')
Expand Down
80 changes: 80 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# pyproject.toml duplicates some information in setup.py
# However, pyproject.toml is now standard, and needed for ruff config
# See also https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
# See also https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
[project]
name = "askbot"
requires-python = ">=3.8"
dynamic = ["version", "dependencies", "scripts", "classifiers", "license",
"description", "readme", "authors", "keywords"]

[tool.setuptools.dynamic]
version = {attr = "askbot.VERSION"}

[tool.ruff]
# exclude Django migrations
extend-exclude = ["**/migrations"]

[tool.ruff.lint]
# add more rules
# see https://docs.astral.sh/ruff/configuration/#using-pyprojecttoml
# "F" contains autoflake, see https://github.com/astral-sh/ruff/issues/1647
# These are all TODO, because they make so many changes.
# I put ** on some to do earlier.
select = [
# default Ruff checkers as of ruff 0.1.3: E4, E7, E9, F
# ** TODO: "E4",
# ** TODO: "E7",
# ** TODO: "E9",
# ** TODO: "F", # pyflakes

# the rest in alphabetical order:
# TODO: "A", # flake8-builtins
# TODO: "ARG", # flake8-unused-arguments
# TODO: "B", # flake8-bugbear
# TODO: "BLE", # flake8-blind-except
# TODO: Do I want "COM", # flake8-commas
# TODO: "C4", # flake8-comprehensions
# ** TODO: "DJ", # flake8-django
# TODO: "DTZ", # flake8-datetimez
# TODO: "EM", # flake8-errmsg
# ** TODO: "EXE", # flake8-executable
# TODO: "FURB", # refurb
# TODO: "FBT", # flake8-boolean-trap
# TODO: "G", # flake8-logging-format
# ** TODO: "I", # isort
# TODO: "ICN", # flake8-import-conventions
# TODO: "INP", # flake8-no-pep420
# TODO: "INT", # flake8-gettext
# TODO: "ISC", # flake8-implicit-str-concat
# TODO: "LOG", # flake8-logging
# TODO: "PERF", # perflint
# TODO: "PIE", # flake8-pie
# TODO: "PL", # pylint
# TODO: "PYI", # flake8-pyi
# TODO: "RET", # flake8-return
# TODO: "RSE", # flake8-raise
# TODO: "RUF",
# TODO: "SIM", # flake8-simplify
# TODO: "SLF", # flake8-self
# TODO: "SLOT", # flake8-slots
# TODO: "TID", # flake8-tidy-imports
# ** TODO: "UP", # pyupgrade
# ** TODO: "Q", # flake8-quotes
# TODO: "TCH", # flake8-type-checking
# TODO: "T10", # flake8-debugger
# ** TODO: "T20", # flake8-print
# TODO: "S", # flake8-bandit
# TODO: "YTT", # flake8-2020
# TODO: add more flake8 rules
]

# rules to ignore globally:
ignore = [
]

[tool.ruff.lint.extend-per-file-ignores]

# per-file ignores
#"**/migrations/*" = ["Q"]
#"**/management/commands/*" = ["T20"]

0 comments on commit 02b50a2

Please sign in to comment.