Probably Polyglossia should offer the possibility of disabling the automatic spacing feature for French in certain contexts such as monospaced text. However, here's how you can do it:
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{xpatch}
\setmainlanguage{french}
\xapptocmd\ttfamily{\XeTeXinterchartokenstate=0 }{}{}
\newcommand{\nospace}[1]{\texttt{#1}}
\begin{document}
\nospace{a:b}
\end{document}
A possibly better workaround is to use \nofrench@punctuation
as you found out:
\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage{xpatch}
\makeatletter
\xapptocmd\ttfamily{\nofrench@punctuation}{}{}
\makeatother
\setmainlanguage{french}
\newcommand{\nospace}[1]{\texttt{#1}}
\begin{document}
\nospace{a:b}
\end{document}
This indeed takes into account the possible usage of LuaLaTeX instead of XeLaTeX.
listings
.