Skip to content

Commit 5c8fa0f

Browse files
authored
improvement/general-housekeeping (#43)
* Update versions Reformat * Linting / precommit for yaml Added prettir Fixed up some files * Removed prettierignore and linted some json and html * Remove support for python 3.7 and add 3.11
1 parent 59deb31 commit 5c8fa0f

File tree

10 files changed

+166
-134
lines changed

10 files changed

+166
-134
lines changed

.github/workflows/publish.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
name: Publish Pypi Package
22

33
on:
4-
push:
5-
tags:
6-
- '*'
4+
push:
5+
tags:
6+
- '*'
77

88
jobs:
9-
package:
10-
runs-on: ubuntu-latest
11-
name: Publish Pypi Package
9+
package:
10+
runs-on: ubuntu-latest
11+
name: Publish Pypi Package
1212

13-
steps:
14-
- name: Cloning repo
15-
uses: actions/checkout@v2
16-
with:
17-
fetch-depth: 0
13+
steps:
14+
- name: Cloning repo
15+
uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 0
1818

19-
- name: Build and publish to pypi
20-
uses: JRubics/[email protected]
21-
with:
22-
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
23-
ignore_dev_requirements: "yes"
24-
build_format: "sdist"
19+
- name: Build and publish to pypi
20+
uses: JRubics/[email protected]
21+
with:
22+
pypi_token: ${{ secrets.PYPI_API_TOKEN }}
23+
ignore_dev_requirements: 'yes'
24+
build_format: 'sdist'

.github/workflows/pytest.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
name: Formatting and Tests
22

33
on:
4-
- pull_request
4+
- pull_request
55

66
jobs:
7-
test:
8-
runs-on: ubuntu-latest
9-
name: Pytest and Black formatting
10-
11-
strategy:
12-
max-parallel: 4
13-
matrix:
14-
python-version: ["3.7", "3.8", "3.9", "3.10"]
15-
16-
steps:
17-
- name: Cloning repo
18-
uses: actions/checkout@v2
19-
with:
20-
fetch-depth: 0
21-
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
24-
with:
25-
python-version: ${{ matrix.python-version }}
26-
27-
- name: Install Dependencies
28-
run: |
29-
python -m pip install --upgrade pip
30-
pip install poetry
31-
poetry install
32-
33-
- name: Check Formatting
34-
run: |
35-
poetry run black --check .
36-
poetry run flake8 .
37-
poetry run isort --check .
38-
39-
- name: Run Tests
40-
run: poetry run pytest
7+
test:
8+
runs-on: ubuntu-latest
9+
name: Pytest and Black formatting
10+
11+
strategy:
12+
max-parallel: 4
13+
matrix:
14+
python-version: ['3.8', '3.9', '3.10', '3.11']
15+
16+
steps:
17+
- name: Cloning repo
18+
uses: actions/checkout@v3
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
27+
- name: Install Dependencies
28+
run: |
29+
python -m pip install --upgrade pip
30+
pip install poetry
31+
poetry install
32+
33+
- name: Check Formatting
34+
run: |
35+
poetry run black --check .
36+
poetry run flake8 .
37+
poetry run isort --check .
38+
39+
- name: Run Tests
40+
run: poetry run pytest

.pre-commit-config.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ repos:
1212
hooks:
1313
- id: black
1414
language_version: python3
15-
15+
- repo: https://github.com/pre-commit/pre-commit-hooks
16+
rev: v4.4.0
17+
hooks:
18+
- id: check-yaml
19+
- repo: https://github.com/pre-commit/mirrors-prettier
20+
rev: v2.7.1
21+
hooks:
22+
- id: prettier

.prettierrc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"proseWrap": "always",
3+
"singleQuote": true,
4+
"printWidth": 120,
5+
"trailingComma": "all",
6+
"tabWidth": 4,
7+
"overrides": [
8+
{
9+
"files": "**/*.md",
10+
"options": {
11+
"tabWidth": 1
12+
}
13+
},
14+
{
15+
"files": ["**/*.yml", "**/*.yaml"],
16+
"options": {
17+
"tabWidth": 2
18+
}
19+
}
20+
]
21+
}

Readme.md

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,30 @@
22

33
# Flagsmith Python SDK
44

5-
> Flagsmith allows you to manage feature flags and remote config across multiple projects, environments and organisations.
5+
> Flagsmith allows you to manage feature flags and remote config across multiple projects, environments and
6+
> organisations.
67
78
The SDK for Python applications for [https://www.flagsmith.com/](https://www.flagsmith.com/).
89

910
## Adding to your project
1011

11-
For full documentation visit [https://docs.flagsmith.com/clients/server-side](https://docs.flagsmith.com/clients/server-side).
12+
For full documentation visit
13+
[https://docs.flagsmith.com/clients/server-side](https://docs.flagsmith.com/clients/server-side).
1214

1315
## Contributing
1416

15-
Please read [CONTRIBUTING.md](https://gist.github.com/kyle-ssg/c36a03aebe492e45cbd3eefb21cb0486) for details on our code of conduct, and the process for submitting pull requests
17+
Please read [CONTRIBUTING.md](https://gist.github.com/kyle-ssg/c36a03aebe492e45cbd3eefb21cb0486) for details on our code
18+
of conduct, and the process for submitting pull requests
1619

1720
## Getting Help
1821

19-
If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search existing issues in order to prevent duplicates.
22+
If you encounter a bug or feature request we would like to hear about it. Before you submit an issue please search
23+
existing issues in order to prevent duplicates.
2024

2125
## Get in touch
2226

23-
If you have any questions about our projects you can email <a href="mailto:[email protected]">[email protected]</a>.
27+
If you have any questions about our projects you can email
28+
2429

2530
## Useful links
2631

example/readme.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Flagsmith Basic Python Example
22

3-
This directory contains a basic Flask application which utilises Flagsmith. To run the example application, you'll
4-
need to go through the following steps:
3+
This directory contains a basic Flask application which utilises Flagsmith. To run the example application, you'll need
4+
to go through the following steps:
55

66
1. Create an account, organisation and project on [Flagsmith](https://flagsmith.com)
77
2. Create a feature in the project called "secret_button"
8-
3. Give the feature a value using the json editor as follows:
8+
3. Give the feature a value using the json editor as follows:
99

1010
```json
11-
{"colour": "#ababab"}
11+
{ "colour": "#ababab" }
1212
```
1313

14-
4. Create a .env file from the template located in this directory with the environment key of one of the environments
15-
in flagsmith (This can be found on the 'settings' page accessed from the menu on the left under the chosen environment.)
14+
4. Create a .env file from the template located in this directory with the environment key of one of the environments in
15+
flagsmith (This can be found on the 'settings' page accessed from the menu on the left under the chosen environment.)
1616
5. From a terminal window, export those environment variables (either manually or by using `export $(cat .env)`)
1717
6. Run the app using `flask run`
1818
7. Browse to http://localhost:5000
1919

2020
Now you can play around with the 'secret_button' feature in flagsmith, turn it on to show it and edit the colour in the
2121
json value to edit the colour of the button. You can also identify as a given user and then update the settings for the
22-
secret button feature for that user in the flagsmith interface to see the affect that has too.
22+
secret button feature for that user in the flagsmith interface to see the affect that has too.

example/templates/home.html

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<head>
33
<style></style>
44
</head>
55
<title>Flagsmith Example</title>
66
<body>
7-
<p>Hello, {{ identifier or 'World' }}.</p>
8-
{% if show_button %}
9-
<button style="background-color: {{ button_colour }}">A secret button</button>
10-
{% endif %}
7+
<p>Hello, {{ identifier or 'World' }}.</p>
8+
{% if show_button %}
9+
<button style="background-color: {{ button_colour }}">A secret button</button>
10+
{% endif %}
1111

12-
<p></p>
12+
<p></p>
1313

14-
<form action="/" method="GET">
15-
<h3>Identify as a user</h3>
16-
<label for="identifier">Identifier: </label><input name="identifier" id="identifier"><br>
14+
<form action="/" method="GET">
15+
<h3>Identify as a user</h3>
16+
<label for="identifier">Identifier: </label><input name="identifier" id="identifier" /><br />
1717

18-
<p>... with an optional user trait</p>
19-
<label for="trait-key">Trait key: </label><input name="trait-key" id="trait-key"><br>
20-
<label for="trait-value">Trait value: </label><input name="trait-value" id="trait-value"><br><br>
18+
<p>... with an optional user trait</p>
19+
<label for="trait-key">Trait key: </label><input name="trait-key" id="trait-key" /><br />
20+
<label for="trait-value">Trait value: </label><input name="trait-value" id="trait-value" /><br /><br />
2121

22-
<button type="submit">Identify!</button>
23-
</form>
24-
25-
</body>
22+
<button type="submit">Identify!</button>
23+
</form>
24+
</body>

tests/data/environment.json

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,56 @@
11
{
2-
"api_key": "B62qaMZNwfiqT76p38ggrQ",
3-
"project": {
4-
"name": "Test project",
5-
"organisation": {
6-
"feature_analytics": false,
7-
"name": "Test Org",
8-
"id": 1,
9-
"persist_trait_data": true,
10-
"stop_serving_flags": false
11-
},
12-
"id": 1,
13-
"hide_disabled_flags": false,
14-
"segments": [
15-
{
2+
"api_key": "B62qaMZNwfiqT76p38ggrQ",
3+
"project": {
4+
"name": "Test project",
5+
"organisation": {
6+
"feature_analytics": false,
7+
"name": "Test Org",
8+
"id": 1,
9+
"persist_trait_data": true,
10+
"stop_serving_flags": false
11+
},
1612
"id": 1,
17-
"name": "Test segment",
18-
"rules": [
19-
{
20-
"type": "ALL",
21-
"rules": [
22-
{
23-
"type": "ALL",
24-
"rules": [],
25-
"conditions": [
26-
{
27-
"operator": "EQUAL",
28-
"property_": "foo",
29-
"value": "bar"
30-
}
13+
"hide_disabled_flags": false,
14+
"segments": [
15+
{
16+
"id": 1,
17+
"name": "Test segment",
18+
"rules": [
19+
{
20+
"type": "ALL",
21+
"rules": [
22+
{
23+
"type": "ALL",
24+
"rules": [],
25+
"conditions": [
26+
{
27+
"operator": "EQUAL",
28+
"property_": "foo",
29+
"value": "bar"
30+
}
31+
]
32+
}
33+
]
34+
}
3135
]
32-
}
33-
]
34-
}
36+
}
3537
]
36-
}
38+
},
39+
"segment_overrides": [],
40+
"id": 1,
41+
"feature_states": [
42+
{
43+
"multivariate_feature_state_values": [],
44+
"feature_state_value": "some-value",
45+
"id": 1,
46+
"featurestate_uuid": "40eb539d-3713-4720-bbd4-829dbef10d51",
47+
"feature": {
48+
"name": "some_feature",
49+
"type": "STANDARD",
50+
"id": 1
51+
},
52+
"segment_id": null,
53+
"enabled": true
54+
}
3755
]
38-
},
39-
"segment_overrides": [],
40-
"id": 1,
41-
"feature_states": [
42-
{
43-
"multivariate_feature_state_values": [],
44-
"feature_state_value": "some-value",
45-
"id": 1,
46-
"featurestate_uuid": "40eb539d-3713-4720-bbd4-829dbef10d51",
47-
"feature": {
48-
"name": "some_feature",
49-
"type": "STANDARD",
50-
"id": 1
51-
},
52-
"segment_id": null,
53-
"enabled": true
54-
}
55-
]
56-
}
56+
}

tests/data/flags.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
"identity": null,
1818
"feature_segment": null
1919
}
20-
]
20+
]

tests/data/identities.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@
2626
"feature_segment": null
2727
}
2828
]
29-
}
29+
}

0 commit comments

Comments
 (0)