Skip to content

Commit

Permalink
Mark all constants as final
Browse files Browse the repository at this point in the history
  • Loading branch information
Limych committed Feb 21, 2022
1 parent e200098 commit ba8876a
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ if ! pytest; then
fi

const_path=$(find custom_components/ -name const.py)
version=$(grep "^VERSION =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/")
version=$(grep "^VERSION: Final =" ${const_path} | sed -E "s/^[^\"]+\"([^\"]*).*$/\\1/")

if [[ -z $1 ]]; then
log.fatal "Please, describe new version number as first argument."
Expand All @@ -108,7 +108,7 @@ fi
new=$(validate_version "${1}")

log.info "Patch files to version '${new}'..."
sed -i -E "s/(^VERSION = \")[^\"]*/\\1${new}/" ${const_path}
sed -i -E "s/(^VERSION: Final = \")[^\"]*/\\1${new}/" ${const_path}
./bin/update_manifest
if output=$(git status --porcelain) && [[ -n "$output" ]]; then
git commit -a --no-verify -m "Bump version to ${new}"
Expand Down
36 changes: 19 additions & 17 deletions custom_components/integration_blueprint/const.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
"""Constants for integration_blueprint."""

# Base component constants
NAME = "Integration blueprint"
DOMAIN = "integration_blueprint"
VERSION = "0.1.0"
ATTRIBUTION = "Data provided by http://jsonplaceholder.typicode.com/"
ISSUE_URL = "https://github.com/Limych/ha-blueprint/issues"
from typing import Final

STARTUP_MESSAGE = f"""
NAME: Final = "Integration blueprint"
DOMAIN: Final = "integration_blueprint"
VERSION: Final = "0.1.0"
ATTRIBUTION: Final = "Data provided by http://jsonplaceholder.typicode.com/"
ISSUE_URL: Final = "https://github.com/Limych/ha-blueprint/issues"

STARTUP_MESSAGE: Final = f"""
-------------------------------------------------------------------
{NAME}
Version: {VERSION}
Expand All @@ -18,24 +20,24 @@
"""

# Icons
ICON = "mdi:format-quote-close"
ICON: Final = "mdi:format-quote-close"

# Device classes
BINARY_SENSOR_DEVICE_CLASS = "connectivity"
BINARY_SENSOR_DEVICE_CLASS: Final = "connectivity"

# Platforms
BINARY_SENSOR = "binary_sensor"
SENSOR = "sensor"
SWITCH = "switch"
PLATFORMS = [BINARY_SENSOR, SENSOR, SWITCH]
BINARY_SENSOR: Final = "binary_sensor"
SENSOR: Final = "sensor"
SWITCH: Final = "switch"
PLATFORMS: Final = [BINARY_SENSOR, SENSOR, SWITCH]

# Configuration and options
CONF_ENABLED = "enabled"
CONF_USERNAME = "username"
CONF_PASSWORD = "password"
CONF_ENABLED: Final = "enabled"
CONF_USERNAME: Final = "username"
CONF_PASSWORD: Final = "password"

# Defaults
DEFAULT_NAME = DOMAIN
DEFAULT_NAME: Final = DOMAIN

# Attributes
ATTR_INTEGRATION = "integration"
ATTR_INTEGRATION: Final = "integration"
8 changes: 4 additions & 4 deletions custom_components/integration_blueprint/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"domain": "integration_blueprint",
"name": "Integration blueprint",
"version": "0.1.0",
"domain": "",
"name": "",
"version": "",
"documentation": "https://github.com/Limych/ha-blueprint",
"issue_tracker": "https://github.com/Limych/ha-blueprint/issues",
"issue_tracker": "",
"dependencies": [],
"config_flow": true,
"codeowners": [
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "Integration blueprint",
"name": "",
"hacs": "1.6.0",
"domains": [
"binary_sensor",
Expand Down

0 comments on commit ba8876a

Please sign in to comment.