1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-06 05:12:21 +01:00

update script

This commit is contained in:
J. Nick Koston
2025-07-22 19:20:28 -10:00
parent 8ae2b31a2f
commit 5b8ae6ed1a

View File

@@ -575,13 +575,15 @@ def lint_namespace(fname, content):
expected_name = re.match( expected_name = re.match(
r"^esphome/components/([^/]+)/.*", fname.replace(os.path.sep, "/") r"^esphome/components/([^/]+)/.*", fname.replace(os.path.sep, "/")
).group(1) ).group(1)
search = f"namespace {expected_name}" # Check for both old style and C++17 nested namespace syntax
if search in content: search_old = f"namespace {expected_name}"
search_new = f"namespace esphome::{expected_name}"
if search_old in content or search_new in content:
return None return None
return ( return (
"Invalid namespace found in C++ file. All integration C++ files should put all " "Invalid namespace found in C++ file. All integration C++ files should put all "
"functions in a separate namespace that matches the integration's name. " "functions in a separate namespace that matches the integration's name. "
f"Please make sure the file contains {highlight(search)}" f"Please make sure the file contains {highlight(search_old)} or {highlight(search_new)}"
) )