In France – unlike the UK – you are legally obliged to show photo identification if you are stopped and asked to by a police officer. This is called a ‘Contrôle d’Identité’.
There are a variety of police powers that allow the French police to check identity, including powers which do not need any specific grounds for selecting you. They can also demand to see proof of your right to be in the country if they suspect you are foreign (this could be based on things like holding banners in English, or having a UK numberplate but cannot be based on racial appearance).
You can be searched during a contrôle. This should just be a pat down over outer clothes, should be done by an officer “of the same sex”, and should not involve looking in pockets or bags. However a more thorough search can be carried out if you are suspected of an offense.
If you do not show photo ID, you can be taken to a police station for the purposes of establishing your identity (‘vérification d’identité’). You are likely to be photographed and to have your fingerprints taken. This is not the same as being arrested, although you can potentially be placed in police custody during or afterwards. You can only be held for up to 4 hours for a ‘vérification’. You can be held for up to 16 hours for the purposes of establishing your immigration status.
It is ‘compulsory’ to provide your identity, but there is no statutory offense for not doing so. During mass arrests, some groups choose to collectively refuse to give their identities to protect each other and slow proceedings. It is an offense to give a false identity.