I think you need to focus on finding the tonic.
Say, I have identified the notes of a song, and they belong to this set [c d e f# g a b]
That does not tell us the tonic so it's getting ahead of things to try identifying key/mode from just a set of pitches.
When finding the tonic you might go by the pitches of the melody, but also consider finding the tonic chord. You might encounter a melody built around the third or fifth scale degree in which case the tonic will be somewhere in the accompaniment.
When we know the tonic the set c d e f# g a b will actually then tell us the mode. Let's say the tonic is G. The set of tones tells us the mode is major. If C were the tonic, lydian is the modes, etc. etc.
Also, the melody might not contain all tones for a complete key signature so don't just look at the melody only, look at the accompaniment, and consider the possibility of choosing a key with less than a full key signature. You might have something like a melody based on a G pentatonic line G A B D E and accompaniment with G major and D major chords. That would leave you with no C, no fourth scale degree. You might say it is impossible to determine whether it's G major or G lydian. It's probably best to go with what is most common and say it's in G major. I wouldn't call it lydian without a conspicuous C#.
Now I end up wondering if this song is in the key of c major (with f# as accidental) or in the key of g major (with f as accidental).
So, the first option would be C lydian, and the second would be G major. Technically you don't have an accidental in either case, because F# is part of the key signatures. A case of a true accidental would be something like C major with most F's being natural, then an "accidental" F# moving up to G. In a nutshell, a progression like this C F C C | D D G G | G G G7 G7 | C C C C.
That kind of example is trickier, because of the chromaticism with F natural and F#, but the important point is still about determining the tonic is C, then determining the mode and what is an accidental versus tones of the key/mode.
When deciding about chromatic tones like F natural and F# in the example above the traditional method is to look at phrase endings, cadences, rather than how often either of the tones occurs. The music could have a lot of F# to G in the phrase, but if it ends G7 C where the F natural is used to move to an ending on the C chord, we consider the phrase ending the definitive thing and say F natural is in the key signature and all the F#'s were accidental, chromatic tones.
Find the tonic, either in the melody or accompaniment, then determine the key/mode. Traditionally phrase endings determine key.