The purpose of the HAL_PCDEx_SetConnectionState() function is not well defined in the function's comment block in the generated usbd_conf.c. If one were only familiar with the L4 parts, it would be surprising to have this function defined in usbd_conf.c and not called. Only with some familiarity with how this function is used with other parts (those without an internal pull-up on DP), is it clear why this function exists.
This function should be removed from the STM32L4 template files since it is never called for these parts.
Also, the purpose of this function (enabling/disabling DP pull-up) should be clearly mentioned in the comment block.