MCPcopy Create free account
hub / github.com/FastLED/FastLED / is_forbidden_command

Function is_forbidden_command

ci/hooks/check_forbidden_commands.py:111–130  ·  view source on GitHub ↗

Check if command starts with a forbidden standalone command. Returns (forbidden_command, recommendation) if found, None otherwise.

(command: str)

Source from the content-addressed store, hash-verified

109
110
111def is_forbidden_command(command: str) -> tuple[str, str] | None:
112 """
113 Check if command starts with a forbidden standalone command.
114
115 Returns (forbidden_command, recommendation) if found, None otherwise.
116 """
117 # Remove leading/trailing whitespace
118 command = command.strip()
119
120 # Check if command starts with any forbidden command as a standalone word
121 for forbidden in FORBIDDEN_COMMANDS:
122 # Match forbidden command at start, followed by whitespace or nothing
123 pattern = rf"^{re.escape(forbidden)}(\s|$)"
124 if re.match(pattern, command):
125 recommendation = COMMAND_RECOMMENDATIONS.get(
126 forbidden, f'set environment variable "{OVERRIDE_ENV_VAR}"'
127 )
128 return (forbidden, recommendation)
129
130 return None
131
132
133def check_forbidden_pattern(command: str) -> tuple[bool, str] | None:

Callers 1

mainFunction · 0.85

Calls 1

getMethod · 0.45

Tested by

no test coverage detected