If I file for bankruptcy, will it affect my co-signer?

No bankruptcy itself would not affect your co-signor or a joint borrower; however they would continue to be responsible for the debt as they agreed to pay it if the primary borrower did not.
Bankruptcy would not affect the creditor’s right to go after anyone who guaranteed or co-signed a loan. An individual’s bankruptcy would only protect them from their creditors, not other people such as co-signers, joint applicants on loans or guarantors.
If you have a joint debt or have co-signed a debt for someone who enters into bankruptcy, the responsibility of the debt would shift to the guarantor and they should contact the lending institution to make payments arrangements, so the debt does not fall into arrears.(This would affect their credit rating).