From 32bb5005b075427910790e0443302df9358efdbe Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 08:21:31 +0800 Subject: [PATCH 01/11] chore: move ChangeLog.md content to CHANGELOG.md and drop it --- CHANGELOG.md | 30 ++++++++++++++++++++++++++++++ ChangeLog.old | 37 ------------------------------------- 2 files changed, 30 insertions(+), 37 deletions(-) delete mode 100644 ChangeLog.old diff --git a/CHANGELOG.md b/CHANGELOG.md index 13f3023..8a43d1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -84,8 +84,38 @@ ### 0.0.4 (2019-07-31) +* 2019-07-31 a143018 Add put method to the client (vst@vsthost.com) +* 2019-05-30 764faa8 Create client from profile (vst@vsthost.com) +* 2019-05-18 5f52572 (chore) Bump version to 0.0.4.dev0 (vst@vsthost.com) + ### 0.0.3 (2019-05-18) +* 2019-05-18 90e269d Merge branch '0.0.3' (vst@vsthost.com) +* 2019-05-18 9eaf384 (fix) Fix README.md and setup.py (vst@vsthost.com) +* 2019-05-18 bd7b714 (fix) Fix packaging (vst@vsthost.com) +* 2019-05-18 79e7758 (release) Update change log (vst@vsthost.com) +* 2019-05-18 2d88cb1 (release) Bump version to 0.0.3 (vst@vsthost.com) +* 2019-05-18 6176470 (chore) Adapt setup to README.md (vst@vsthost.com) +* 2019-05-18 0e4ad31 (chore) Convert README from .rst to .md (vst@vsthost.com) +* 2019-05-18 b3e58f9 (chore) Upgrade requests dependency (vst@vsthost.com) +* 2019-05-18 643cb5f (chore) Rename package to decaf.api.client (vst@vsthost.com) +* 2019-04-16 bb66fda (chore) Version bumped to 0.0.3.dev0 (vst@vsthost.com) + ### 0.0.2 (2019-04-16) +* 2019-04-16 1984637 Merge branch '0.0.2' (vst@vsthost.com) +* 2019-04-16 747dd8c (release) Change log updated (vst@vsthost.com) +* 2019-04-16 d3cdc74 (release) Version bumped to 0.0.2 (vst@vsthost.com) +* 2019-03-07 23be6ea (improve) Support for remote value collections (vst@vsthost.com) +* 2019-03-07 77c19bc (fix) Entity endpoint attribute fix (vst@vsthost.com) +* 2019-03-06 d13ba17 (improve) Request timeouts and exception handling (vst@vsthost.com) +* 2019-03-05 779002b (chore) Revisit dev dependencies (vst@vsthost.com) +* 2019-03-05 e590bd8 (chore) Version bumped to 0.0.2.dev0 (vst@vsthost.com) + ### 0.0.1 (2019-03-05) + +* 2019-03-05 3b3ebcb Merge branch '0.0.1' (vst@vsthost.com) +* 2019-03-05 d663296 (release) Change log updated (vst@vsthost.com) +* 2019-03-05 b4a0bdc (release) Version bumped to 0.0.1 (vst@vsthost.com) +* 2019-03-05 afd8b3b Initial code commit (vst@vsthost.com) +* 2019-03-05 a90b4dc Initial commit (vst@vsthost.com) \ No newline at end of file diff --git a/ChangeLog.old b/ChangeLog.old deleted file mode 100644 index bee6a47..0000000 --- a/ChangeLog.old +++ /dev/null @@ -1,37 +0,0 @@ -VERS: 2019-07-31 ------- 0.0.4 - - * 2019-07-31 a143018 Add put method to the client (vst@vsthost.com) - * 2019-05-30 764faa8 Create client from profile (vst@vsthost.com) - * 2019-05-18 5f52572 [chore] Bump version to 0.0.4.dev0 (vst@vsthost.com) - -VERS: 2019-05-18 1bcd54a 0.0.3 (vst@vsthost.com) - - * 2019-05-18 90e269d Merge branch '0.0.3' (vst@vsthost.com) - * 2019-05-18 9eaf384 [fix] Fix README.md and setup.py (vst@vsthost.com) - * 2019-05-18 bd7b714 [fix] Fix packaging (vst@vsthost.com) - * 2019-05-18 79e7758 [release] Update change log (vst@vsthost.com) - * 2019-05-18 2d88cb1 [release] Bump version to 0.0.3 (vst@vsthost.com) - * 2019-05-18 6176470 [chore] Adapt setup to README.md (vst@vsthost.com) - * 2019-05-18 0e4ad31 [chore] Convert README from .rst to .md (vst@vsthost.com) - * 2019-05-18 b3e58f9 [chore] Upgrade requests dependency (vst@vsthost.com) - * 2019-05-18 643cb5f [chore] Rename package to decaf.api.client (vst@vsthost.com) - * 2019-04-16 bb66fda [chore] Version bumped to 0.0.3.dev0 (vst@vsthost.com) - -VERS: 2019-04-16 6dc6615 0.0.2 (vst@vsthost.com) - - * 2019-04-16 1984637 Merge branch '0.0.2' (vst@vsthost.com) - * 2019-04-16 747dd8c [release] Change log updated (vst@vsthost.com) - * 2019-04-16 d3cdc74 [release] Version bumped to 0.0.2 (vst@vsthost.com) - * 2019-03-07 23be6ea [improve] Support for remote value collections (vst@vsthost.com) - * 2019-03-07 77c19bc [fix] Entity endpoint attribute fix (vst@vsthost.com) - * 2019-03-06 d13ba17 [improve] Request timeouts and exception handling (vst@vsthost.com) - * 2019-03-05 779002b [chore] Revisit dev dependencies (vst@vsthost.com) - * 2019-03-05 e590bd8 [chore] Version bumped to 0.0.2.dev0 (vst@vsthost.com) - -VERS: 2019-03-05 86589d3 0.0.1 (vst@vsthost.com) - - * 2019-03-05 3b3ebcb Merge branch '0.0.1' (vst@vsthost.com) - * 2019-03-05 d663296 [release] Change log updated (vst@vsthost.com) - * 2019-03-05 b4a0bdc [release] Version bumped to 0.0.1 (vst@vsthost.com) - * 2019-03-05 afd8b3b Initial code commit (vst@vsthost.com) - * 2019-03-05 a90b4dc Initial commit (vst@vsthost.com) From 3a979345fceb969e06598352026e45f79f7c3f1b Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 08:23:07 +0800 Subject: [PATCH 02/11] refactor(dev)!: switch to pyproject.toml, pyproject.nix --- .gitignore | 1 + flake.lock | 118 ++++++++++++++++++++++++++++ flake.nix | 79 +++++++++++++++++++ nix/sources.json | 14 ---- nix/sources.nix | 194 ----------------------------------------------- pyproject.toml | 81 ++++++++++++++++++-- setup.cfg | 5 -- setup.py | 37 --------- shell.nix | 36 --------- 9 files changed, 273 insertions(+), 292 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 nix/sources.json delete mode 100644 nix/sources.nix delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 9cbc079..3e823ed 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ /pip-wheel-metadata /tmp/ __pycache__ +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..eb7b007 --- /dev/null +++ b/flake.lock @@ -0,0 +1,118 @@ +{ + "nodes": { + "mdbook-nixdoc": { + "inputs": { + "nix-github-actions": [ + "pyproject-nix", + "nix-github-actions" + ], + "nixpkgs": [ + "pyproject-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1708395692, + "narHash": "sha256-smf0VmxGbjJDZqKvxxG3ZVqubgbVwAWG26wPo+BT/A0=", + "owner": "adisbladis", + "repo": "mdbook-nixdoc", + "rev": "d6a71b114b9221c0b4f20d31b81766d072cc26be", + "type": "github" + }, + "original": { + "owner": "adisbladis", + "repo": "mdbook-nixdoc", + "type": "github" + } + }, + "nix-github-actions": { + "inputs": { + "nixpkgs": [ + "pyproject-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1720066371, + "narHash": "sha256-uPlLYH2S0ACj0IcgaK9Lsf4spmJoGejR9DotXiXSBZQ=", + "owner": "nix-community", + "repo": "nix-github-actions", + "rev": "622f829f5fe69310a866c8a6cd07e747c44ef820", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nix-github-actions", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1727202669, + "narHash": "sha256-yjPUKP7FYQ49reYOf5/H1DdBIBkOcOy2LifxlDF0F1I=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "656f967583f9f725b16f94172ccba2ec541c70f1", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "release-24.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pyproject-nix": { + "inputs": { + "mdbook-nixdoc": "mdbook-nixdoc", + "nix-github-actions": "nix-github-actions", + "nixpkgs": [ + "nixpkgs" + ], + "treefmt-nix": "treefmt-nix" + }, + "locked": { + "lastModified": 1726093189, + "narHash": "sha256-aPzd6M1k1H0C2zoMlSfAdTg4Za+WfB8Qj+OAbQAVAMs=", + "owner": "nix-community", + "repo": "pyproject.nix", + "rev": "6c56846759ba16382bc2bdbee42c2f56c21654be", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "pyproject.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "pyproject-nix": "pyproject-nix" + } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "pyproject-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1724833132, + "narHash": "sha256-F4djBvyNRAXGusJiNYInqR6zIMI3rvlp6WiKwsRISos=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "3ffd842a5f50f435d3e603312eefa4790db46af5", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d9e8289 --- /dev/null +++ b/flake.nix @@ -0,0 +1,79 @@ +{ + description = "Flake to develop, test, build and publish DECAF API Client for Python."; + + inputs.nixpkgs.url = "github:nixos/nixpkgs/release-24.05"; + inputs.pyproject-nix.url = "github:nix-community/pyproject.nix"; + inputs.pyproject-nix.inputs.nixpkgs.follows = "nixpkgs"; + + outputs = { nixpkgs, pyproject-nix, ... }: + let + inherit (nixpkgs) lib; + + ## Use x86_64-linux for simplicity: + pkgs = nixpkgs.legacyPackages.x86_64-linux; + + ## Load pyproject.toml: + project = pyproject-nix.lib.project.loadPyproject { + ## Read and unmarshal pyproject.toml relative to this flake (project root): + projectRoot = ./.; + }; + + ## Use default nixpkgs Python3 interpreter and package set but override pydantic: + python = pkgs.python3.override { + packageOverrides = self: super: { + pydantic = super.pydantic_1; + }; + }; + + ## Get the library version: + version = builtins.head (builtins.match ''.*__version__[ ]*=[ ]*"(.*)".*'' (builtins.readFile ./decaf/api/client/__init__.py)); + in + { + ## Create default development shell containing dependencies from pyproject.toml: + devShells.x86_64-linux.default = + let + arg = project.renderers.withPackages { + inherit python; + extras = [ "test" "dev" ]; + }; + pythonEnv = python.withPackages arg; + in + pkgs.mkShell { + packages = [ + pythonEnv + ]; + }; + + ## Build our package using `buildPythonPackage`: + packages.x86_64-linux.default = + let + attrs = project.renderers.buildPythonPackage { + inherit python; + extras = [ "test" ]; + }; + in + python.pkgs.buildPythonPackage (attrs // { + version = version; + + nativeCheckInputs = [ + python.pkgs.isort + python.pkgs.black + python.pkgs.mypy + python.pkgs.pytest + python.pkgs.flake8 + ]; + + checkPhase = '' + runHook preCheck + + isort --diff --check decaf/ + black --check decaf/ + mypy --config-file tox.ini --namespace-packages decaf/api/client + flake8 + pytest --verbose --ignore=setup.py --ignore-glob=tmp/* --doctest-modules + + runHook postCheck + ''; + }); + }; +} diff --git a/nix/sources.json b/nix/sources.json deleted file mode 100644 index b647a62..0000000 --- a/nix/sources.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "nixpkgs": { - "branch": "release-22.11", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "feda52be1d59f13b9aa02f064b4f14784b9a06c8", - "sha256": "13ic4a7n719x5yjmd0138hdh2sggcrw4iwkfrq8ili0y5b602g6b", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/feda52be1d59f13b9aa02f064b4f14784b9a06c8.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index 9a01c8a..0000000 --- a/nix/sources.nix +++ /dev/null @@ -1,194 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - if spec ? ref then spec.ref else - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!"; - submodules = if spec ? submodules then spec.submodules else false; - submoduleArg = - let - nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; - emptyArgWithWarning = - if submodules == true - then - builtins.trace - ( - "The niv input \"${name}\" uses submodules " - + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " - + "does not support them" - ) - {} - else {}; - in - if nixSupportsSubmodules - then { inherit submodules; } - else emptyArgWithWarning; - in - builtins.fetchGit - ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import {} - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if isNull (builtins.match "[a-zA-Z0-9]" c) then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else {}; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (!isNull name) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs ( - name: spec: - if builtins.hasAttr "outPath" spec - then abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if isNull sourcesFile then {} else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig {}) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/pyproject.toml b/pyproject.toml index 37f2a9f..03f6448 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,13 +1,82 @@ +[project] +name = "decaf-api-client" +dynamic = ["version"] +description = "DECAF API Client" +readme = "README.md" +requires-python = ">=3.10" +license = { file = "LICENSE" } +keywords = ["decaf", "api", "client", "finance"] +authors = [{ name = "Vehbi Sinan Tunalioglu", email = "vst@vsthost.com" }] +maintainers = [{ name = "Vehbi Sinan Tunalioglu", email = "vst@vsthost.com" }] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", +] +dependencies = [ + "pydantic>=1,<2", + "requests>=2,<3", + "typing-extensions>=3.7.4.3", +] + + +[project.optional-dependencies] +test = [ + "black", + "flake8", + "isort", + "mypy", + "pytest", + "tox", + "types-requests", +] + +dev = [ + "build", + "ipython", + "pip", + "pyls-flake8", + "pyls-isort", + "pylsp-mypy", + "pylsp-rope", + "python-lsp-black", + "python-lsp-server", + "rope", + "twine", + "wheel", +] + + +[project.urls] +homepage = "https://github.com/telostat/decaf-api-client-python" +documentation = "https://github.com/telostat/decaf-api-client-python" +repository = "https://github.com/telostat/decaf-api-client-python" +changelog = "https://github.com/teloscube/decaf-client-python/blob/main/CHANGELOG.md" + + +[build-system] +requires = ["setuptools >= 61.0"] +build-backend = "setuptools.build_meta" + + +[tool.setuptools.dynamic] +version = { attr = "decaf.api.client.__version__" } + + +[tool.setuptools.packages.find] +include = ["decaf.api.client"] + + [tool.black] line-length = 120 -target_version = ["py37"] -exclude = ''' -/( -)/ -''' +target_version = ["py311"] -[tool.isort] +[tool.isort] line_length = 120 multi_line_output = 3 include_trailing_comma = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index d4f0979..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[metadata] -license-file = LICENSE - -[bdist_wheel] -python-tag = py37.py38.py39.py310.py311 diff --git a/setup.py b/setup.py deleted file mode 100644 index 666398a..0000000 --- a/setup.py +++ /dev/null @@ -1,37 +0,0 @@ -import os -import re - -from setuptools import setup, find_namespace_packages - -setup( - name="decaf-api-client", - version=re.search(r"__version__\s*=\s*['\"]([^'\"]*)['\"]", open("decaf/api/client/__init__.py").read()).group(1), - description="DECAF API Client", - long_description=open(os.path.join(os.path.abspath(os.path.dirname(__file__)), "README.md")).read(), - long_description_content_type="text/markdown", - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - ], - author="Vehbi Sinan Tunalioglu", - author_email="vst@vsthost.com", - url="https://github.com/telostat/decaf-api-client-python", - package_data={"decaf.api.client": ["py.typed"]}, - packages=find_namespace_packages(include=["decaf.*"]), - include_package_data=True, - zip_safe=False, - install_requires=[ - "pydantic>=1,<2", - "requests>=2,<3", - "typing-extensions>=3.7.4.3", - ], - dependency_links=[], - scripts=[], -) diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 460721c..0000000 --- a/shell.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ python ? "python310" -, ... -}: - -let - ## Import Nix packages: - pkgs = import (import ./nix/sources.nix).nixpkgs { }; - - ## Define Python packages: - python-packages = p: with p; [ - ## Production dependencies: - pydantic - requests - typing-extensions - - ## Development and testing dependencies: - black - flake8 - ipython - isort - mypy - pytest - tox - twine - types-requests - wheel - ]; - - ## Get a Python with our dependencies: - this-python = pkgs.${python}.withPackages python-packages; -in -pkgs.mkShell { - packages = [ - this-python - ]; -} From 5e2bae19736014eb3f3a89dfb457519566018b9d Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 10:53:21 +0800 Subject: [PATCH 03/11] chore(deps): drop typing-extensions dependency --- decaf/api/client/endpoints/stocks.py | 4 +--- decaf/api/client/machinery.py | 2 +- decaf/api/client/utils.py | 4 +--- pyproject.toml | 1 - 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/decaf/api/client/endpoints/stocks.py b/decaf/api/client/endpoints/stocks.py index 5883d23..1bc0538 100644 --- a/decaf/api/client/endpoints/stocks.py +++ b/decaf/api/client/endpoints/stocks.py @@ -7,9 +7,7 @@ import datetime from decimal import Decimal from enum import Enum -from typing import List, Optional - -from typing_extensions import Literal +from typing import List, Literal, Optional from ..machinery import BaseResource, ResourceEndpoint, query from ..types import GUID, AccountId, ArtifactId, ArtifactTypeId, InstitutionId, PortfolioId, TeamId diff --git a/decaf/api/client/machinery.py b/decaf/api/client/machinery.py index 79428cc..cb017c5 100644 --- a/decaf/api/client/machinery.py +++ b/decaf/api/client/machinery.py @@ -56,6 +56,7 @@ Generic, Iterable, List, + Literal, Optional, Set, TextIO, @@ -69,7 +70,6 @@ import requests from pydantic import BaseModel, Field from requests.auth import AuthBase -from typing_extensions import Literal @dataclass(frozen=True) diff --git a/decaf/api/client/utils.py b/decaf/api/client/utils.py index 95f2ab1..acd240e 100644 --- a/decaf/api/client/utils.py +++ b/decaf/api/client/utils.py @@ -16,9 +16,7 @@ from decimal import Decimal from itertools import groupby -from typing import Callable, Dict, Iterable, Optional, Tuple, TypeVar, Union - -from typing_extensions import Protocol +from typing import Callable, Dict, Iterable, Optional, Protocol, Tuple, TypeVar, Union from .types import Date, DateTime diff --git a/pyproject.toml b/pyproject.toml index 03f6448..9ed3faf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,6 @@ classifiers = [ dependencies = [ "pydantic>=1,<2", "requests>=2,<3", - "typing-extensions>=3.7.4.3", ] From c689658a5d87c2fc0eb1994013bbd33501947401 Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 10:57:33 +0800 Subject: [PATCH 04/11] test: put mypy configuration inside pyproject.toml --- flake.nix | 2 +- pyproject.toml | 17 +++++++++++++++++ tox.ini | 20 +------------------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/flake.nix b/flake.nix index d9e8289..5b80b43 100644 --- a/flake.nix +++ b/flake.nix @@ -68,7 +68,7 @@ isort --diff --check decaf/ black --check decaf/ - mypy --config-file tox.ini --namespace-packages decaf/api/client + mypy --namespace-packages decaf/api/client flake8 pytest --verbose --ignore=setup.py --ignore-glob=tmp/* --doctest-modules diff --git a/pyproject.toml b/pyproject.toml index 9ed3faf..9edc687 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,3 +79,20 @@ target_version = ["py311"] line_length = 120 multi_line_output = 3 include_trailing_comma = true + +[tool.mypy] +check_untyped_defs = true +disallow_untyped_calls = true +disallow_untyped_defs = true +no_implicit_optional = true +strict_optional = true +warn_incomplete_stub = true +warn_redundant_casts = true +warn_return_any = true +warn_unused_ignores = true +ignore_missing_imports = true +disallow_subclassing_any = true +disallow_any_generics = true + +## enable pydantic plugin: +plugins = "pydantic.mypy" diff --git a/tox.ini b/tox.ini index 9897773..f400a7b 100644 --- a/tox.ini +++ b/tox.ini @@ -1,23 +1,5 @@ [tox] -[mypy] - -## Checking options (We want as strict as possible): -check_untyped_defs = True -disallow_untyped_calls = True -disallow_untyped_defs = True -no_implicit_optional = True -strict_optional = True -warn_incomplete_stub = True -warn_redundant_casts = True -warn_return_any = True -warn_unused_ignores = True -ignore_missing_imports=True -disallow_subclassing_any = True -disallow_any_generics = True - -## Enable pydantic plugin: -plugins = pydantic.mypy [flake8] @@ -65,6 +47,6 @@ deps = commands = isort --diff --check decaf/ black --check decaf/ - mypy --install-types --non-interactive --config-file tox.ini --namespace-packages decaf/api/client + mypy --install-types --non-interactive --namespace-packages decaf/api/client flake8 pytest --verbose --ignore=setup.py --ignore-glob=tmp/* --doctest-modules From eef71fe2c7d7c8ca28e0ba6e74a09ba56085b6b5 Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 11:14:01 +0800 Subject: [PATCH 05/11] test: drop tox, move flake8 configuration from tox.ini to .flake8 --- tox.ini => .flake8 | 22 ++-------------------- 1 file changed, 2 insertions(+), 20 deletions(-) rename tox.ini => .flake8 (65%) diff --git a/tox.ini b/.flake8 similarity index 65% rename from tox.ini rename to .flake8 index f400a7b..c608e97 100644 --- a/tox.ini +++ b/.flake8 @@ -1,6 +1,3 @@ -[tox] - - [flake8] ## Define error messages to be ignored. @@ -13,15 +10,15 @@ exclude = *.egg-info, *.py[codi], .cache, - .mypy_cache, - __static, .eggs, .git, + .mypy_cache, .tox, __pycache__, build, dev, dist, + result, tmp ## Defines maximum MCCABE complexity allowed. @@ -35,18 +32,3 @@ doctests = True ## Indicates that we want summary statistics of error messages, if any. statistics = True - -[testenv] - -deps = - black - flake8 - isort - mypy - pytest -commands = - isort --diff --check decaf/ - black --check decaf/ - mypy --install-types --non-interactive --namespace-packages decaf/api/client - flake8 - pytest --verbose --ignore=setup.py --ignore-glob=tmp/* --doctest-modules From 36bce04501ddf76c75d731db91e4e3c3901cde3f Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 11:14:47 +0800 Subject: [PATCH 06/11] chore(build): reformat and revisit pyproject.toml --- pyproject.toml | 55 ++++++++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 33 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9edc687..d1cab35 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,44 +9,33 @@ keywords = ["decaf", "api", "client", "finance"] authors = [{ name = "Vehbi Sinan Tunalioglu", email = "vst@vsthost.com" }] maintainers = [{ name = "Vehbi Sinan Tunalioglu", email = "vst@vsthost.com" }] classifiers = [ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", -] -dependencies = [ - "pydantic>=1,<2", - "requests>=2,<3", + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", ] +dependencies = ["pydantic>=1,<2", "requests>=2,<3"] [project.optional-dependencies] -test = [ - "black", - "flake8", - "isort", - "mypy", - "pytest", - "tox", - "types-requests", -] +test = ["black", "flake8", "isort", "mypy", "pytest", "types-requests"] dev = [ - "build", - "ipython", - "pip", - "pyls-flake8", - "pyls-isort", - "pylsp-mypy", - "pylsp-rope", - "python-lsp-black", - "python-lsp-server", - "rope", - "twine", - "wheel", + "build", + "ipython", + "pip", + "pyls-flake8", + "pyls-isort", + "pylsp-mypy", + "pylsp-rope", + "python-lsp-black", + "python-lsp-server", + "rope", + "twine", + "wheel", ] @@ -72,7 +61,7 @@ include = ["decaf.api.client"] [tool.black] line-length = 120 -target_version = ["py311"] +target-version = ["py310"] [tool.isort] From 70a2799734400c7192ec37eade983f5aac89bc06 Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 11:22:18 +0800 Subject: [PATCH 07/11] chore(build): drop MANIFEST.in --- MANIFEST.in | 3 --- pyproject.toml | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) delete mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index a6b1c71..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include README.md -include LICENSE -recursive-include decaf *.typed diff --git a/pyproject.toml b/pyproject.toml index d1cab35..96fc4fc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -59,6 +59,10 @@ version = { attr = "decaf.api.client.__version__" } include = ["decaf.api.client"] +[tool.setuptools.package-data] +"decaf.api.client" = ["py.typed"] + + [tool.black] line-length = 120 target-version = ["py310"] From 970f16ea21d593d707bd9775888187097432f3d7 Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 12:06:14 +0800 Subject: [PATCH 08/11] chore(deps): upgrade pydantic to v2 --- flake.nix | 6 +----- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/flake.nix b/flake.nix index 5b80b43..8c6c27b 100644 --- a/flake.nix +++ b/flake.nix @@ -19,11 +19,7 @@ }; ## Use default nixpkgs Python3 interpreter and package set but override pydantic: - python = pkgs.python3.override { - packageOverrides = self: super: { - pydantic = super.pydantic_1; - }; - }; + python = pkgs.python3; ## Get the library version: version = builtins.head (builtins.match ''.*__version__[ ]*=[ ]*"(.*)".*'' (builtins.readFile ./decaf/api/client/__init__.py)); diff --git a/pyproject.toml b/pyproject.toml index 96fc4fc..cbe99ee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ classifiers = [ "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", ] -dependencies = ["pydantic>=1,<2", "requests>=2,<3"] +dependencies = ["pydantic>=2,<3", "requests>=2,<3"] [project.optional-dependencies] From 07317ec6582ea4a4001044edc4d266f0ba8c106a Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 12:30:47 +0800 Subject: [PATCH 09/11] test: update GitHub Action for testing the package --- .github/workflows/test.yml | 31 +++++++++++++++++++------------ flake.nix | 2 +- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61ed166..f35b25b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,23 +6,30 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: "ubuntu-latest" strategy: matrix: python: - - "3.7" - - "3.8" - - "3.9" - "3.10" - "3.11" + - "3.12" steps: - - uses: actions/checkout@v3 - - name: Setup Python - uses: actions/setup-python@v4 + - name: "Checkout codebase" + uses: "actions/checkout@v4" + - name: "Setup Python" + uses: "actions/setup-python@v5" with: - python-version: ${{ matrix.python }} - - name: Install tox and any other packages - run: pip install tox - - name: Run tox - run: tox -e py + python-version: "${{ matrix.python }}" + - name: "Install Package with Test Dependencies" + run: "pip install -e \".[test]\"" + - name: "Run Tests: isort" + run: "isort --diff --check decaf/" + - name: "Run Tests: black" + run: "black --check decaf/" + - name: "Run Tests: mypy" + run: "mypy --namespace-packages --package decaf.api.client" + - name: "Run Tests: flake8" + run: "flake8" + - name: "Run Tests: pytest" + run: "pytest --verbose --doctest-modules" diff --git a/flake.nix b/flake.nix index 8c6c27b..425cfac 100644 --- a/flake.nix +++ b/flake.nix @@ -64,7 +64,7 @@ isort --diff --check decaf/ black --check decaf/ - mypy --namespace-packages decaf/api/client + mypy --namespace-packages --package decaf.api.client flake8 pytest --verbose --ignore=setup.py --ignore-glob=tmp/* --doctest-modules From d9cedec1504094c3e7507da29bf7d7011966b3a7 Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 12:53:53 +0800 Subject: [PATCH 10/11] chore(release): integrate Release Please --- .github/workflows/release.yaml | 19 +++++++++++++++++++ .github/workflows/{test.yml => test.yaml} | 0 .release-please-manifest.json | 3 +++ decaf/api/client/__init__.py | 2 +- release-please-config.json | 18 ++++++++++++++++++ 5 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yaml rename .github/workflows/{test.yml => test.yaml} (100%) create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4e65d92 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,19 @@ +name: "Release" + +on: + push: + branches: + - "main" + +permissions: + contents: "write" + pull-requests: "write" + +jobs: + release-please: + runs-on: "ubuntu-latest" + + steps: + - name: "Release" + uses: "googleapis/release-please-action@v4" + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yaml similarity index 100% rename from .github/workflows/test.yml rename to .github/workflows/test.yaml diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..4a34d5c --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.0.11" +} diff --git a/decaf/api/client/__init__.py b/decaf/api/client/__init__.py index 99cf503..abf7be5 100644 --- a/decaf/api/client/__init__.py +++ b/decaf/api/client/__init__.py @@ -1,2 +1,2 @@ #: Defines the name of the :mod:`decaf.api.client` package. -__version__ = "0.0.12.dev0" +__version__ = "0.0.12.dev0" # x-release-please-version diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..e1641f0 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,18 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "bootstrap-sha": "742184cc4db4d7c3f91ea2af4675b7b68455881f", + "packages": { + ".": { + "release-type": "python", + "changelog-path": "CHANGELOG.md", + "include-v-in-tag": false, + "bump-minor-pre-major": false, + "bump-patch-for-minor-pre-major": false, + "draft": false, + "prerelease": true, + "extra-files": [ + "decaf/api/client/__init__.py" + ] + } + } +} From 3a7415cf1f7c178a7678d4ea5e5bd9d7b1c2b522 Mon Sep 17 00:00:00 2001 From: Vehbi Sinan Tunalioglu Date: Wed, 25 Sep 2024 13:01:04 +0800 Subject: [PATCH 11/11] docs: update README and LICENSE --- LICENSE | 2 +- README.md | 31 ++++++++++--------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/LICENSE b/LICENSE index f9eb232..8934819 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ Copyright (2017-2019) Vehbi Sinan Tunalioglu. -Copyright (2019-2023) Teloscube Pte Ltd. +Copyright (2019-2024) Teloscube Pte Ltd. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are diff --git a/README.md b/README.md index 98d3b55..6301064 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # DECAF API Client (Python) -[![Github](https://github.com/telostat/decaf-api-client-python/workflows/Install%20and%20Test/badge.svg)](https://github.com/telostat/decaf-api-client-python/actions) +[![Test](https://github.com/teloscube/decaf-client-python/actions/workflows/test.yml/badge.svg)](https://github.com/teloscube/decaf-client-python/actions/workflows/test.yml) > **TODO:** Provide a complete README file. @@ -9,27 +9,13 @@ A Nix shell is provided for development: ```sh -nix-shell +nix develop ``` -Run tests: +Build to run tests: ```sh -tox -``` - -Open the codebase in Visual Studio Code: - -```sh -code . -``` - -Alternatively, you can issue following commands directly without entering the -Nix shell: - -```sh -nix-shell --arg python "\"python39\"" --run tox -nix-shell --arg python "\"python310\"" --run tox +nix build ``` ## Build and Publish @@ -37,7 +23,7 @@ nix-shell --arg python "\"python310\"" --run tox Build the source distribution: ```sh -python setup.py sdist bdist_wheel +python -m build --sdist --wheel ``` Check the distribution(s): @@ -54,5 +40,8 @@ twine upload -s dist/* ## License and Copyrights -This software is licensed under [The 3-Clause BSD -License](https://opensource.org/licenses/BSD-3-Clause). +This software is licensed under [The 3-Clause BSD License]. + + + +[The 3-Clause BSD License]: https://opensource.org/licenses/BSD-3-Clause