Let's consider a simpler example:
\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand\TestArg{mO{x}}{%
1: #1, 2: #2
}
\begin{document}
\TestArg{a}[b]
\TestArg{a} [b]
\end{document}
This produces

You can clearly see that in the second case [b] is not recognized as an optional argument; instead, the default value x is used and [b] is printed separately, with a space in front of it.
A new line counts as a space, so it's not a surprise if also
\TestArg
{a}
[b]
produces the same result.
This was a precise choice when the interface of xparse was developed. The team followed the example of amsmath that doesn't allow spaces in front of optional arguments to \\, because of the infamous
\left[\begin{array}{cc}
1 & 2 \\
[1] & [2]
\end{array}\right]
that raises an error, because [1] is mistaken for the optional argument to \\. Instead
\begin{bmatrix}
1 & 2 \\
[1] & [2]
\end{bmatrix}
works flawlessly.
The input \TestArg{a} [b] is deemed ambiguous. There were two choices, the team followed the path of considering [b] not an optional argument.
You get the same behavior with
\documentclass{article}
\usepackage{xparse}
\NewDocumentCommand\TestArg{mD(){x}}{%
1: #1, 2: #2
}
\begin{document}
\TestArg{a}(b)
\TestArg{a} (b)
\end{document}
In my opinion, one should never define macros with seven arguments. In your case two are for the variants, four are optional and one is mandatory.
A key-value interface would be much better:
\TestArg[
var-a=true,
var-b=false,
opt-A=Three,
opt-B=Four,
opt-C=Six,
opt-D=Seven,
]{Five}
By the way, {\empty} does not specify an empty default value: if tested with \tl_if_empty:nTF{#3}, a missing first optional argument would make LaTeX follow the false branch.
\@ifnextcharsees the space at the end of the line instead of the(or[. I don't know why this doesn't happen for the first ones, though. – Phelype Oleinik Mar 21 '18 at 23:18D()on one line and{\empty}on the next. By the way, why{\empty}and not{}? – egreg Mar 21 '18 at 23:29xparsewas being developed, optional arguments cannot be on a new line; precisely, there cannot even be a space before them. – egreg Mar 21 '18 at 23:32{\empty}, this is not empty. – egreg Mar 21 '18 at 23:40\@ifnextcharhandling so that\\newline[a+b]in the first array cell of the next line is not misinterpreted as\\[a+b]and give an error that a+b isn't a length – David Carlisle Mar 21 '18 at 23:43\emptyas the default value of an argument as it just makes things be slower, xparse inserts\emptythat then expands to nothing, rather than making the default{}in which case xparse inserts nothing – David Carlisle Mar 21 '18 at 23:54\item[foo]), etc. – Joseph Wright Mar 22 '18 at 07:14