diff --git a/CHANGELOG.md b/CHANGELOG.md index 6504357..de75d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Change log + +## 0.7.0 + +* `constants.py` has been renamed to `config.py` to better reflect how it is used. + ## 0.6.3 * Packaged application installs in the correct location. Resolving [#6](https://github.com/phalt/clientele/issues/6) diff --git a/clientele/client_template/http.py b/clientele/client_template/http.py index bcd787e..87fb05d 100644 --- a/clientele/client_template/http.py +++ b/clientele/client_template/http.py @@ -3,7 +3,7 @@ import httpx # noqa -from . import constants as c # noqa +from . import config as c # noqa class APIException(Exception): diff --git a/clientele/constants_template.py b/clientele/config_template.py similarity index 100% rename from clientele/constants_template.py rename to clientele/config_template.py diff --git a/clientele/generator.py b/clientele/generator.py index 66b8826..1086d34 100644 --- a/clientele/generator.py +++ b/clientele/generator.py @@ -74,10 +74,10 @@ def generate_manifest(self): def generate(self) -> None: copy_tree(src=CLIENT_TEMPLATE_ROOT, dst=self.output_dir) - if not exists(f"{self.output_dir}/constants.py"): + if not exists(f"{self.output_dir}/config.py"): copyfile( - f"{CONSTANTS_ROOT}/constants_template.py", - f"{self.output_dir}/constants.py", + f"{CONSTANTS_ROOT}/config_template.py", + f"{self.output_dir}/config.py", ) self.generate_manifest() self.schemas_generator.generate_schema_classes() diff --git a/clientele/generators/http.py b/clientele/generators/http.py index b663b50..2cbcc01 100644 --- a/clientele/generators/http.py +++ b/clientele/generators/http.py @@ -64,7 +64,7 @@ def generate_http_content(self) -> None: client_type=client_type, ) console.log( - f"[yellow]Please see {self.output_dir}constants.py to set authentication variables" + f"[yellow]Please see {self.output_dir}config.py to set authentication variables" ) elif info["type"] == "oauth2": template = templates.get_template("bearer_client.jinja2") diff --git a/clientele/settings.py b/clientele/settings.py index 271be48..33b1a75 100644 --- a/clientele/settings.py +++ b/clientele/settings.py @@ -7,6 +7,6 @@ ) TEMPLATES_ROOT = dirname(dirname(abspath(__file__))) + "/clientele/templates/" CONSTANTS_ROOT = dirname(dirname(abspath(__file__))) + "/clientele/" -VERSION = "0.6.3" +VERSION = "0.7.0" templates = Environment(loader=PackageLoader("clientele", "templates")) diff --git a/docs/examples.md b/docs/examples.md index 8ceb47b..5ef5868 100644 --- a/docs/examples.md +++ b/docs/examples.md @@ -22,7 +22,7 @@ Run it now and you will see this output: my_client/ __init__.py client.py - constants.py + config.py http.py MANIFEST schemas.py @@ -179,9 +179,9 @@ class ExampleEnum(str, Enum): One of the problems with auto-generated clients is that you often need to configure them, and if you try and regenerate the client at some point then your configuration gets wiped clean and you have to do it all over again. -Clientele solves this problem by providing an entry point for configuration that will never be overwritten - `constants.py`. +Clientele solves this problem by providing an entry point for configuration that will never be overwritten - `config.py`. -When you first generate the project, you will see a file called `constants.py` and it will offer configuration functions a bit like this: +When you first generate the project, you will see a file called `config.py` and it will offer configuration functions a bit like this: ```python """ @@ -228,10 +228,10 @@ Then clientele will provide you information on the environment variables you nee make this work during the generation. For example: ```sh -Please see my_client/constants.py to set authentication variables +Please see my_client/config.py to set authentication variables ``` -The `constants.py` file will have entry points for you to configure, for example, HTTP Bearer authentication will need the `get_bearer_token` function to be updated, something like this: +The `config.py` file will have entry points for you to configure, for example, HTTP Bearer authentication will need the `get_bearer_token` function to be updated, something like this: ```py @@ -247,7 +247,7 @@ def get_bearer_token() -> str: ### Additional headers -If you want to pass specific headers with all requests made by the client, you can configure the `additional_headers` function in `constants.py` to do this. +If you want to pass specific headers with all requests made by the client, you can configure the `additional_headers` function in `config.py` to do this. ```py def additional_headers() -> dict: diff --git a/docs/install.md b/docs/install.md index 18fc41e..18bf4e7 100644 --- a/docs/install.md +++ b/docs/install.md @@ -10,5 +10,5 @@ Once installed you can run `clientele version` to make sure you have the latest ```sh > clientele version -clientele 0.6.3 +clientele 0.7.0 ``` diff --git a/pyproject.toml b/pyproject.toml index 8637b12..f8b0f18 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "clientele" -version = "0.6.3" +version = "0.7.0" description = "Generate loveable Python HTTP API Clients" authors = ["Paul Hallett "] license = "MIT" diff --git a/tests/async_test_client/MANIFEST.md b/tests/async_test_client/MANIFEST.md index 6fae34b..f69842a 100644 --- a/tests/async_test_client/MANIFEST.md +++ b/tests/async_test_client/MANIFEST.md @@ -9,7 +9,7 @@ pipx install clientele API VERSION: 0.1.0 OPENAPI VERSION: 3.0.2 -CLIENTELE VERSION: 0.6.3 +CLIENTELE VERSION: 0.7.0 Generated using this command: diff --git a/tests/async_test_client/constants.py b/tests/async_test_client/config.py similarity index 100% rename from tests/async_test_client/constants.py rename to tests/async_test_client/config.py diff --git a/tests/async_test_client/http.py b/tests/async_test_client/http.py index 4603486..ef72ed8 100644 --- a/tests/async_test_client/http.py +++ b/tests/async_test_client/http.py @@ -3,7 +3,7 @@ import httpx # noqa -from . import constants as c # noqa +from . import config as c # noqa class APIException(Exception): diff --git a/tests/test_async_generated_client.py b/tests/test_async_generated_client.py index 0cd8d1f..e8dd7f0 100644 --- a/tests/test_async_generated_client.py +++ b/tests/test_async_generated_client.py @@ -8,9 +8,9 @@ from httpx import Response from respx import MockRouter -from .async_test_client import client, constants, http, schemas +from .async_test_client import client, config, http, schemas -BASE_URL = constants.api_base_url() +BASE_URL = config.api_base_url() @pytest.mark.asyncio diff --git a/tests/test_client/MANIFEST.md b/tests/test_client/MANIFEST.md index 6558e7c..7c0e437 100644 --- a/tests/test_client/MANIFEST.md +++ b/tests/test_client/MANIFEST.md @@ -9,7 +9,7 @@ pipx install clientele API VERSION: 0.1.0 OPENAPI VERSION: 3.0.2 -CLIENTELE VERSION: 0.6.3 +CLIENTELE VERSION: 0.7.0 Generated using this command: diff --git a/tests/test_client/constants.py b/tests/test_client/config.py similarity index 93% rename from tests/test_client/constants.py rename to tests/test_client/config.py index e831115..ec58365 100644 --- a/tests/test_client/constants.py +++ b/tests/test_client/config.py @@ -8,7 +8,7 @@ def additional_headers() -> dict: """ - Modify this function ot provide additional headers to all + Modify this function to provide additional headers to all HTTP requests made by this client. """ return {} diff --git a/tests/test_client/http.py b/tests/test_client/http.py index a6aed4f..7fc516e 100644 --- a/tests/test_client/http.py +++ b/tests/test_client/http.py @@ -3,7 +3,7 @@ import httpx # noqa -from . import constants as c # noqa +from . import config as c # noqa class APIException(Exception): diff --git a/tests/test_generated_client.py b/tests/test_generated_client.py index 5420f2c..6555270 100644 --- a/tests/test_generated_client.py +++ b/tests/test_generated_client.py @@ -4,9 +4,9 @@ from httpx import Response from respx import MockRouter -from .test_client import client, constants, http, schemas +from .test_client import client, config, http, schemas -BASE_URL = constants.api_base_url() +BASE_URL = config.api_base_url() @pytest.mark.respx(base_url=BASE_URL)