-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c410690
commit 45c2079
Showing
10 changed files
with
217 additions
and
162 deletions.
There are no files selected for viewing
This file contains 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 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,38 @@ | ||
default_install_hook_types: | ||
- pre-commit | ||
- pre-push | ||
- commit-msg | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
# - id: check-yaml | ||
- id: end-of-file-fixer | ||
stages: [pre-commit] | ||
- id: trailing-whitespace | ||
stages: [pre-commit] | ||
- id: debug-statements | ||
stages: [pre-push] | ||
|
||
## Isort | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
name: isort | ||
stages: [pre-commit] | ||
|
||
## Black | ||
- repo: https://github.com/psf/black | ||
rev: 23.3.0 | ||
hooks: | ||
- id: black | ||
stages: [pre-commit] | ||
|
||
## Ruff | ||
- repo: https://github.com/charliermarsh/ruff-pre-commit | ||
rev: v0.0.260 | ||
hooks: | ||
- id: ruff | ||
stages: [pre-commit] |
This file contains 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 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 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 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,56 +0,0 @@ | ||
""" | ||
Tests for plugin.py. | ||
Tests are written using the pytest library (https://docs.pytest.org), and you | ||
should read the testing guidelines in the CKAN docs: | ||
https://docs.ckan.org/en/2.9/contributing/testing.html | ||
To write tests for your extension you should install the pytest-ckan package: | ||
pip install pytest-ckan | ||
This will allow you to use CKAN specific fixtures on your tests. | ||
For instance, if your test involves database access you can use `clean_db` to | ||
reset the database: | ||
import pytest | ||
from ckan.tests import factories | ||
@pytest.mark.usefixtures("clean_db") | ||
def test_some_action(): | ||
dataset = factories.Dataset() | ||
# ... | ||
For functional tests that involve requests to the application, you can use the | ||
`app` fixture: | ||
from ckan.plugins import toolkit | ||
def test_some_endpoint(app): | ||
url = toolkit.url_for('myblueprint.some_endpoint') | ||
response = app.get(url) | ||
assert response.status_code == 200 | ||
To temporary patch the CKAN configuration for the duration of a test you can use: | ||
import pytest | ||
@pytest.mark.ckan_config("ckanext.myext.some_key", "some_value") | ||
def test_some_action(): | ||
pass | ||
""" | ||
import ckanext.charts.plugin as plugin | ||
|
||
|
||
@pytest.mark.ckan_config("ckan.plugins", "charts") | ||
@pytest.mark.usefixtures("with_plugins") | ||
def test_plugin(): | ||
assert plugin_loaded("charts") | ||
This file contains 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 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,127 @@ | ||
[tool.black] | ||
# line-length = 88 | ||
# preview = true | ||
|
||
[tool.ruff] | ||
target-version = "py38" | ||
select = [ | ||
# "B", # likely bugs and design problems | ||
# "BLE", # do not catch blind exception | ||
# "C40", # better list/set/dict comprehensions | ||
# "C90", # check McCabe complexity | ||
# "COM", # trailing commas | ||
"E", # pycodestyle error | ||
# "W", # pycodestyle warning | ||
"F", # pyflakes | ||
# "G", # format strings for logging statements | ||
# "N", # naming conventions | ||
# "PL", # pylint | ||
# "PT", # pytest style | ||
# "PIE", # misc lints | ||
# "Q", # preferred quoting style | ||
# "RET", # improvements for return statements | ||
# "RSE", # improvements for rise statements | ||
# "S", # security testing | ||
# "SIM", # simplify code | ||
# "T10", # debugging statements | ||
# "T20", # print statements | ||
# "TID", # tidier imports | ||
# "TRY", # better exceptions | ||
# "UP", # upgrade syntax for newer versions of the language | ||
] | ||
ignore = [ | ||
"E712", # comparison to bool: violated by SQLAlchemy filters | ||
"PT004", # fixture does not return anything, add leading underscore: violated by clean_db | ||
"PLC1901", # simplify comparison to empty string: violated by SQLAlchemy filters | ||
] | ||
|
||
[tool.ruff.per-file-ignores] | ||
"ckanext/charts/tests*" = ["S", "PL"] | ||
|
||
[tool.isort] | ||
known_ckan = "ckan" | ||
known_ckanext = "ckanext" | ||
known_self = "ckanext.charts" | ||
sections = "FUTURE,STDLIB,FIRSTPARTY,THIRDPARTY,CKAN,CKANEXT,SELF,LOCALFOLDER" | ||
profile = "black" | ||
|
||
[tool.pytest.ini_options] | ||
addopts = "--ckan-ini test.ini" | ||
filterwarnings = [ | ||
"ignore::sqlalchemy.exc.SADeprecationWarning", | ||
"ignore::sqlalchemy.exc.SAWarning", | ||
"ignore::DeprecationWarning", | ||
] | ||
|
||
[tool.pyright] | ||
pythonVersion = "3.8" | ||
include = ["ckanext"] | ||
exclude = [ | ||
"**/test*", | ||
"**/migration", | ||
] | ||
strict = [] | ||
|
||
strictParameterNoneValue = true | ||
|
||
# Check the meaning of rules here | ||
# https://github.com/microsoft/pyright/blob/main/docs/configuration.md | ||
reportFunctionMemberAccess = true # non-standard member accesses for functions | ||
reportMissingImports = true | ||
reportMissingModuleSource = true | ||
reportMissingTypeStubs = false | ||
reportImportCycles = true | ||
reportUnusedImport = true | ||
reportUnusedClass = true | ||
reportUnusedFunction = true | ||
reportUnusedVariable = true | ||
reportDuplicateImport = true | ||
reportOptionalSubscript = true | ||
reportOptionalMemberAccess = true | ||
reportOptionalCall = true | ||
reportOptionalIterable = true | ||
reportOptionalContextManager = true | ||
reportOptionalOperand = true | ||
reportTypedDictNotRequiredAccess = false # Context won't work with this rule | ||
reportConstantRedefinition = true | ||
reportIncompatibleMethodOverride = true | ||
reportIncompatibleVariableOverride = true | ||
reportOverlappingOverload = true | ||
reportUntypedFunctionDecorator = false | ||
reportUnknownParameterType = true | ||
reportUnknownArgumentType = false | ||
reportUnknownLambdaType = false | ||
reportUnknownMemberType = false | ||
reportMissingTypeArgument = true | ||
reportInvalidTypeVarUse = true | ||
reportCallInDefaultInitializer = true | ||
reportUnknownVariableType = true | ||
reportUntypedBaseClass = true | ||
reportUnnecessaryIsInstance = true | ||
reportUnnecessaryCast = true | ||
reportUnnecessaryComparison = true | ||
reportAssertAlwaysTrue = true | ||
reportSelfClsParameterName = true | ||
reportUnusedCallResult = false # allow function calls for side-effect only | ||
useLibraryCodeForTypes = true | ||
reportGeneralTypeIssues = true | ||
reportPropertyTypeMismatch = true | ||
reportWildcardImportFromLibrary = true | ||
reportUntypedClassDecorator = false | ||
reportUntypedNamedTuple = true | ||
reportPrivateUsage = true | ||
reportPrivateImportUsage = true | ||
reportInconsistentConstructor = true | ||
reportMissingSuperCall = false | ||
reportUninitializedInstanceVariable = true | ||
reportInvalidStringEscapeSequence = true | ||
reportMissingParameterType = true | ||
reportImplicitStringConcatenation = false | ||
reportUndefinedVariable = true | ||
reportUnboundVariable = true | ||
reportInvalidStubStatement = true | ||
reportIncompleteStub = true | ||
reportUnsupportedDunderAll = true | ||
reportUnusedCoroutine = true | ||
reportUnnecessaryTypeIgnoreComment = true | ||
reportMatchNotExhaustive = true |
This file contains 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,3 +1,46 @@ | ||
[metadata] | ||
name = ckanext-charts | ||
version = 0.0.2 | ||
description = | ||
long_description = file: README.md | ||
long_description_content_type = text/markdown | ||
url = https://github.com/DataShades/ckanext-charts | ||
author = Sergey Motornyuk | ||
author_email = [email protected] | ||
license = AGPL | ||
classifiers = | ||
Development Status :: 4 - Beta | ||
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+) | ||
Programming Language :: Python :: 3.8 | ||
Programming Language :: Python :: 3.9 | ||
Programming Language :: Python :: 3.10 | ||
Programming Language :: Python :: 3.11 | ||
|
||
keywords = CKAN | ||
|
||
[options] | ||
python_requires = >= 3.8 | ||
packages = find: | ||
namespace_packages = ckanext | ||
install_requires = | ||
typing-extensions>=4.4.0 | ||
include_package_data = True | ||
|
||
[options.entry_points] | ||
ckan.plugins = | ||
charts = ckanext.charts.plugin:ChartsPlugin | ||
|
||
babel.extractors = | ||
ckan = ckan.lib.extract:extract_ckan | ||
|
||
[options.extras_require] | ||
test = | ||
pytest-ckan | ||
ckanext-toolbelt | ||
|
||
dev = | ||
%(test)s | ||
|
||
[extract_messages] | ||
keywords = translate isPlural | ||
add_comments = TRANSLATORS: | ||
|
@@ -19,9 +62,3 @@ previous = true | |
domain = ckanext-charts | ||
directory = ckanext/charts/i18n | ||
statistics = true | ||
|
||
[tool:pytest] | ||
filterwarnings = | ||
ignore::sqlalchemy.exc.SADeprecationWarning | ||
ignore::sqlalchemy.exc.SAWarning | ||
ignore::DeprecationWarning |
Oops, something went wrong.