Skip to content

Commit 7c90bbb

Browse files
authored
Merge pull request #15 from im-voracity/feature/v1-rewrite
feat: v1.0 SDK rewrite — resource-based API, httpx, pydantic v2
2 parents 6852052 + ea4bc53 commit 7c90bbb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+5073
-2154
lines changed

.env.example

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Credenciais para testes de integração contra a API real da Hotmart.
2+
# Copie este arquivo para .env e preencha com suas credenciais.
3+
# O arquivo .env NÃO deve ser commitado.
4+
5+
HOTMART_CLIENT_ID=seu-client-id
6+
HOTMART_CLIENT_SECRET=seu-client-secret
7+
HOTMART_BASIC=Basic seu-basic-token

.github/workflows/checks.yml

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,34 @@ on:
55
pull_request:
66
branches:
77
- master
8+
push:
9+
branches:
10+
- master
811

912
jobs:
1013
test-lint:
1114
name: Test and Lint
12-
runs-on: ubuntu-20.04
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: ["3.11", "3.12", "3.13"]
19+
1320
steps:
14-
- name: Checkout code
15-
id: checkout
16-
uses: actions/checkout@v2
21+
- uses: actions/checkout@v4
1722

18-
- name: Setup Python
19-
id: python
20-
uses: actions/setup-python@v4
23+
- name: Install uv
24+
uses: astral-sh/setup-uv@v4
2125
with:
22-
python-version: "3.9"
26+
version: "latest"
2327

24-
- name: Install Poetry
25-
uses: snok/install-poetry@v1.3.4
26-
with:
27-
virtualenvs-create: true
28-
virtualenvs-in-project: true
28+
- name: Set up Python ${{ matrix.python-version }}
29+
run: uv python install ${{ matrix.python-version }}
2930

3031
- name: Install dependencies
31-
id: install
32-
run: |
33-
poetry install --no-interaction --all-extras
34-
35-
- name: Run tests
36-
id: tests
37-
run: |
38-
poetry run python -m unittest discover -s tests
39-
if: steps.install.outcome == 'success'
40-
41-
- name: Run flake8
42-
id: flake8
43-
run: |
44-
poetry run flake8
45-
if: steps.install.outcome == 'success'
32+
run: uv sync --all-groups
33+
34+
- name: Lint (ruff)
35+
run: uv run ruff check .
36+
37+
- name: Unit tests
38+
run: uv run pytest tests/ --ignore=tests/test_integration.py -v

.github/workflows/publish.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
name: Publish
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
test:
11+
name: Unit Tests
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Install uv
17+
uses: astral-sh/setup-uv@v4
18+
with:
19+
version: "latest"
20+
21+
- name: Install dependencies
22+
run: uv sync --all-groups
23+
24+
- name: Lint
25+
run: uv run ruff check .
26+
27+
- name: Tests
28+
run: uv run pytest tests/ --ignore=tests/test_integration.py -v
29+
30+
build:
31+
name: Build
32+
runs-on: ubuntu-latest
33+
needs: test
34+
steps:
35+
- uses: actions/checkout@v4
36+
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v4
39+
with:
40+
version: "latest"
41+
42+
- name: Build wheel and sdist
43+
run: uv build
44+
45+
- name: Upload dist artifacts
46+
uses: actions/upload-artifact@v4
47+
with:
48+
name: dist
49+
path: dist/
50+
51+
publish-test-pypi:
52+
name: Publish to Test PyPI
53+
runs-on: ubuntu-latest
54+
needs: build
55+
environment: test-release
56+
permissions:
57+
id-token: write
58+
59+
steps:
60+
- name: Download dist artifacts
61+
uses: actions/download-artifact@v4
62+
with:
63+
name: dist
64+
path: dist/
65+
66+
- name: Publish to Test PyPI
67+
uses: pypa/gh-action-pypi-publish@release/v1
68+
with:
69+
repository-url: https://test.pypi.org/legacy/
70+
71+
publish-pypi:
72+
name: Publish to PyPI
73+
runs-on: ubuntu-latest
74+
needs: publish-test-pypi
75+
environment: release
76+
permissions:
77+
id-token: write
78+
79+
steps:
80+
- name: Download dist artifacts
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: dist
84+
path: dist/
85+
86+
- name: Publish to PyPI
87+
uses: pypa/gh-action-pypi-publish@release/v1

.serena/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/cache
2+
/project.local.yml

.serena/memories/code_style.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Code Style & Conventions
2+
3+
## General
4+
- Line length: 100 characters (ruff)
5+
- Python 3.10+ only
6+
- Type hints required (strict mypy mode)
7+
- English docstrings required (+ PT-BR optional)
8+
- No nested ifs - use early returns / guard clauses
9+
10+
## Formatting
11+
- ruff format (automatic formatting)
12+
- ruff lint with E, F, I, UP, B, SIM rules
13+
- mypy strict mode enabled
14+
15+
## Naming
16+
- Classes: PascalCase
17+
- Functions/methods: snake_case
18+
- Constants: UPPER_SNAKE_CASE
19+
- Private members: _leading_underscore
20+
21+
## Testing
22+
- pytest framework
23+
- Use respx for HTTP mocking
24+
- TDD approach: tests first, then implementation
25+
- Test file location: tests/test_<module>.py
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Hotmart Python SDK v1 Rewrite
2+
3+
## Purpose
4+
Python SDK for the Hotmart API with TDD approach.
5+
6+
## Tech Stack
7+
- Python 3.10+
8+
- httpx >= 0.27, < 1 (HTTP client)
9+
- pydantic >= 2.0, < 3 (data validation)
10+
- pytest (testing)
11+
- respx (mocking HTTP)
12+
- mypy (type checking)
13+
- ruff (linting/formatting)
14+
15+
## Code Structure
16+
- `src/hotmart/` - Main SDK code
17+
- `_exceptions.py` - Custom exceptions (Task 3 done)
18+
- `_config.py` - Configuration (Task 2 done)
19+
- `_logging.py` - Logging setup (Task 4 done)
20+
- `_retry.py` - Retry logic (Task 5 in progress)
21+
- `_rate_limit.py` - Rate limiting (Task 6)
22+
- `_auth.py` - Authentication (Task 7)
23+
- `_base_client.py` - Base client (Task 8)
24+
- `models/` - Data models
25+
- `resources/` - API resources
26+
- `tests/` - Test suite
27+
- `docs/` - Documentation
28+
29+
## Key Commands
30+
- Test: `uv run pytest tests/ -v`
31+
- Single test: `uv run pytest tests/test_file.py -v`
32+
- Format: `ruff format src/ tests/`
33+
- Lint: `ruff check src/ tests/ --fix`
34+
- Type check: `mypy src/`
35+
- All checks: `ruff format && ruff check --fix && mypy src/ && pytest tests/`
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Task Completion Checklist
2+
3+
1. Write tests first (TDD)
4+
2. Run tests to see RED (should fail)
5+
3. Implement the feature
6+
4. Run tests to see GREEN (all pass)
7+
5. Format code: `ruff format src/ tests/`
8+
6. Type check: `mypy src/`
9+
7. Commit with message in format: `feat:` or `fix:` or `test:`
10+
8. Push to remote
11+
9. Report: status, test results, commit hash
12+
13+
## Push Conflicts
14+
If push fails with conflict (Task 5 running in parallel):
15+
- Run: `git pull --rebase`
16+
- Then: `git push`

.serena/project.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
# the name by which the project can be referenced within Serena
2+
project_name: "v1-rewrite"
3+
4+
5+
# list of languages for which language servers are started; choose from:
6+
# al bash clojure cpp csharp
7+
# csharp_omnisharp dart elixir elm erlang
8+
# fortran fsharp go groovy haskell
9+
# java julia kotlin lua markdown
10+
# matlab nix pascal perl php
11+
# php_phpactor powershell python python_jedi r
12+
# rego ruby ruby_solargraph rust scala
13+
# swift terraform toml typescript typescript_vts
14+
# vue yaml zig
15+
# (This list may be outdated. For the current list, see values of Language enum here:
16+
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
17+
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
18+
# Note:
19+
# - For C, use cpp
20+
# - For JavaScript, use typescript
21+
# - For Free Pascal/Lazarus, use pascal
22+
# Special requirements:
23+
# Some languages require additional setup/installations.
24+
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
25+
# When using multiple languages, the first language server that supports a given file will be used for that file.
26+
# The first language is the default language and the respective language server will be used as a fallback.
27+
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
28+
languages:
29+
- python
30+
31+
# the encoding used by text files in the project
32+
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
33+
encoding: "utf-8"
34+
35+
# line ending convention to use when writing source files.
36+
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
37+
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
38+
line_ending:
39+
40+
# The language backend to use for this project.
41+
# If not set, the global setting from serena_config.yml is used.
42+
# Valid values: LSP, JetBrains
43+
# Note: the backend is fixed at startup. If a project with a different backend
44+
# is activated post-init, an error will be returned.
45+
language_backend:
46+
47+
# whether to use project's .gitignore files to ignore files
48+
ignore_all_files_in_gitignore: true
49+
50+
# advanced configuration option allowing to configure language server-specific options.
51+
# Maps the language key to the options.
52+
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
53+
# No documentation on options means no options are available.
54+
ls_specific_settings: {}
55+
56+
# list of additional paths to ignore in this project.
57+
# Same syntax as gitignore, so you can use * and **.
58+
# Note: global ignored_paths from serena_config.yml are also applied additively.
59+
ignored_paths: []
60+
61+
# whether the project is in read-only mode
62+
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
63+
# Added on 2025-04-18
64+
read_only: false
65+
66+
# list of tool names to exclude.
67+
# This extends the existing exclusions (e.g. from the global configuration)
68+
#
69+
# Below is the complete list of tools for convenience.
70+
# To make sure you have the latest list of tools, and to view their descriptions,
71+
# execute `uv run scripts/print_tool_overview.py`.
72+
#
73+
# * `activate_project`: Activates a project by name.
74+
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
75+
# * `create_text_file`: Creates/overwrites a file in the project directory.
76+
# * `delete_lines`: Deletes a range of lines within a file.
77+
# * `delete_memory`: Deletes a memory from Serena's project-specific memory store.
78+
# * `execute_shell_command`: Executes a shell command.
79+
# * `find_referencing_code_snippets`: Finds code snippets in which the symbol at the given location is referenced.
80+
# * `find_referencing_symbols`: Finds symbols that reference the symbol at the given location (optionally filtered by type).
81+
# * `find_symbol`: Performs a global (or local) search for symbols with/containing a given name/substring (optionally filtered by type).
82+
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
83+
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
84+
# * `initial_instructions`: Gets the initial instructions for the current project.
85+
# Should only be used in settings where the system prompt cannot be set,
86+
# e.g. in clients you have no control over, like Claude Desktop.
87+
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
88+
# * `insert_at_line`: Inserts content at a given line in a file.
89+
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
90+
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
91+
# * `list_memories`: Lists memories in Serena's project-specific memory store.
92+
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
93+
# * `prepare_for_new_conversation`: Provides instructions for preparing for a new conversation (in order to continue with the necessary context).
94+
# * `read_file`: Reads a file within the project directory.
95+
# * `read_memory`: Reads the memory with the given name from Serena's project-specific memory store.
96+
# * `remove_project`: Removes a project from the Serena configuration.
97+
# * `replace_lines`: Replaces a range of lines within a file with new content.
98+
# * `replace_symbol_body`: Replaces the full definition of a symbol.
99+
# * `restart_language_server`: Restarts the language server, may be necessary when edits not through Serena happen.
100+
# * `search_for_pattern`: Performs a search for a pattern in the project.
101+
# * `summarize_changes`: Provides instructions for summarizing the changes made to the codebase.
102+
# * `switch_modes`: Activates modes by providing a list of their names
103+
# * `think_about_collected_information`: Thinking tool for pondering the completeness of collected information.
104+
# * `think_about_task_adherence`: Thinking tool for determining whether the agent is still on track with the current task.
105+
# * `think_about_whether_you_are_done`: Thinking tool for determining whether the task is truly completed.
106+
# * `write_memory`: Writes a named memory (for future reference) to Serena's project-specific memory store.
107+
excluded_tools: []
108+
109+
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default).
110+
# This extends the existing inclusions (e.g. from the global configuration).
111+
included_optional_tools: []
112+
113+
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
114+
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
115+
fixed_tools: []
116+
117+
# list of mode names to that are always to be included in the set of active modes
118+
# The full set of modes to be activated is base_modes + default_modes.
119+
# If the setting is undefined, the base_modes from the global configuration (serena_config.yml) apply.
120+
# Otherwise, this setting overrides the global configuration.
121+
# Set this to [] to disable base modes for this project.
122+
# Set this to a list of mode names to always include the respective modes for this project.
123+
base_modes:
124+
125+
# list of mode names that are to be activated by default.
126+
# The full set of modes to be activated is base_modes + default_modes.
127+
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
128+
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
129+
# This setting can, in turn, be overridden by CLI parameters (--mode).
130+
default_modes:
131+
132+
# initial prompt for the project. It will always be given to the LLM upon activating the project
133+
# (contrary to the memories, which are loaded on demand).
134+
initial_prompt: ""
135+
136+
# time budget (seconds) per tool call for the retrieval of additional symbol information
137+
# such as docstrings or parameter information.
138+
# This overrides the corresponding setting in the global configuration; see the documentation there.
139+
# If null or missing, use the setting from the global configuration.
140+
symbol_info_budget:
141+
142+
# list of regex patterns which, when matched, mark a memory entry as read‑only.
143+
# Extends the list from the global configuration, merging the two lists.
144+
read_only_memory_patterns: []
145+
146+
# list of regex patterns for memories to completely ignore.
147+
# Matching memories will not appear in list_memories or activate_project output
148+
# and cannot be accessed via read_memory or write_memory.
149+
# To access ignored memory files, use the read_file tool on the raw file path.
150+
# Extends the list from the global configuration, merging the two lists.
151+
# Example: ["_archive/.*", "_episodes/.*"]
152+
ignored_memory_patterns: []

0 commit comments

Comments
 (0)